Skip to content

Commit

Permalink
Merge pull request #12106 from nextcloud/update/material-design-library
Browse files Browse the repository at this point in the history
Update M3 library, Increase target sdk to 34
  • Loading branch information
AndyScherzinger authored Nov 17, 2023
2 parents 23d120e + 6303028 commit f09c3da
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 58 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ android {

defaultConfig {
minSdkVersion 24
targetSdkVersion 33
compileSdk 33
targetSdkVersion 34
compileSdk 34

buildConfigField 'boolean', 'CI', ciBuild.toString()
buildConfigField 'boolean', 'RUNTIME_PERF_ANALYSIS', perfAnalysis.toString()
Expand Down Expand Up @@ -246,7 +246,7 @@ dependencies {
implementation 'org.apache.jackrabbit:jackrabbit-webdav:2.13.5' // remove after entire switch to lib v2
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.9.0'
implementation 'com.google.android.material:material:1.10.0'
implementation 'com.jakewharton:disklrucache:2.0.2'
implementation "androidx.appcompat:appcompat:$appCompatVersion"
implementation 'androidx.webkit:webkit:1.7.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class ActivitiesActivityIT : AbstractIT() {
sut.dismissSnackbar()
}

shortSleep()
longSleep()
waitForIdleSync()

screenshot(sut)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import javax.inject.Inject;

import androidx.activity.OnBackPressedCallback;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
Expand Down Expand Up @@ -115,6 +116,8 @@ protected void onCreate(Bundle savedInstanceState) {
}
transaction.commit();
}

getOnBackPressedDispatcher().addCallback(this, onBackPressedCallback);
}

@Override
Expand All @@ -137,12 +140,14 @@ public void onTransferStateChanged(OCFile file, boolean downloading, boolean upl
// not needed
}

@Override
public void onBackPressed() {
if (getSupportFragmentManager().findFragmentByTag(BackupListFragment.TAG) != null) {
getSupportFragmentManager().popBackStack(BACKUP_TO_LIST, FragmentManager.POP_BACK_STACK_INCLUSIVE);
} else {
finish();
private final OnBackPressedCallback onBackPressedCallback = new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
if (getSupportFragmentManager().findFragmentByTag(BackupListFragment.TAG) != null) {
getSupportFragmentManager().popBackStack(BACKUP_TO_LIST, FragmentManager.POP_BACK_STACK_INCLUSIVE);
} else {
finish();
}
}
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import android.view.ActionMode
import android.view.Menu
import android.view.MenuItem
import android.view.View
import androidx.activity.OnBackPressedCallback
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import com.google.android.material.button.MaterialButton
import com.nextcloud.client.di.Injectable
Expand Down Expand Up @@ -125,9 +126,33 @@ open class FolderPickerActivity :

// sets message for empty list of folders
setBackgroundText()

handleOnBackPressed()

Log_OC.d(TAG, "onCreate() end")
}

private fun handleOnBackPressed() {
onBackPressedDispatcher.addCallback(
this,
object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
val listOfFiles = listOfFilesFragment
if (listOfFiles != null) {
// should never be null, indeed
val levelsUp = listOfFiles.onBrowseUp()
if (levelsUp == 0) {
finish()
return
}
file = listOfFiles.currentFile
updateUiElements()
}
}
}
)
}

override fun onActionModeStarted(mode: ActionMode) {
super.onActionModeStarted(mode)
if (account != null) {
Expand Down Expand Up @@ -321,20 +346,6 @@ open class FolderPickerActivity :
}
}

override fun onBackPressed() {
val listOfFiles = listOfFilesFragment
if (listOfFiles != null) {
// should never be null, indeed
val levelsUp = listOfFiles.onBrowseUp()
if (levelsUp == 0) {
finish()
return
}
file = listOfFiles.currentFile
updateUiElements()
}
}

private fun updateUiElements() {
toggleChooseEnabled()
updateNavigationElementsInActionBar()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@

import javax.inject.Inject;

import androidx.activity.OnBackPressedCallback;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.ActionBar;
Expand Down Expand Up @@ -258,6 +259,8 @@ public void onNothingSelected(AdapterView<?> parent) {

checkWritableFolder(mCurrentDir);

getOnBackPressedDispatcher().addCallback(this, onBackPressedCallback);

Log_OC.d(TAG, "onCreate() end");
}

Expand Down Expand Up @@ -369,43 +372,45 @@ private boolean isSearchOpen() {
}
}

@Override
public void onBackPressed() {
if (isSearchOpen() && mSearchView != null) {
mSearchView.setQuery("", false);
mFileListFragment.onClose();
mSearchView.onActionViewCollapsed();
setDrawerIndicatorEnabled(isDrawerIndicatorAvailable());
} else {
if (mDirectories.getCount() <= SINGLE_DIR) {
finish();
return;
}
private final OnBackPressedCallback onBackPressedCallback = new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
if (isSearchOpen() && mSearchView != null) {
mSearchView.setQuery("", false);
mFileListFragment.onClose();
mSearchView.onActionViewCollapsed();
setDrawerIndicatorEnabled(isDrawerIndicatorAvailable());
} else {
if (mDirectories.getCount() <= SINGLE_DIR) {
finish();
return;
}

File parentFolder = mCurrentDir.getParentFile();
if (!parentFolder.canRead()) {
checkLocalStoragePathPickerPermission();
return;
}
File parentFolder = mCurrentDir.getParentFile();
if (!parentFolder.canRead()) {
checkLocalStoragePathPickerPermission();
return;
}

popDirname();
mFileListFragment.onNavigateUp();
mCurrentDir = mFileListFragment.getCurrentDirectory();
checkWritableFolder(mCurrentDir);
popDirname();
mFileListFragment.onNavigateUp();
mCurrentDir = mFileListFragment.getCurrentDirectory();
checkWritableFolder(mCurrentDir);

if (mCurrentDir.getParentFile() == null) {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(false);
if (mCurrentDir.getParentFile() == null) {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(false);
}
}
}

// invalidate checked state when navigating directories
if (!mLocalFolderPickerMode) {
setSelectAllMenuItem(mOptionsMenu.findItem(R.id.action_select_all), false);
// invalidate checked state when navigating directories
if (!mLocalFolderPickerMode) {
setSelectAllMenuItem(mOptionsMenu.findItem(R.id.action_select_all), false);
}
}
}
}
};

@Override
protected void onSaveInstanceState(@NonNull Bundle outState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class LocalConnectionTest {

// THEN
// no binding is performed
verify(exactly = 0) { context.bindService(any(), any(), any()) }
verify(exactly = 0) { context.bindService(any(), any(), Context.BIND_AUTO_CREATE) }
}

@Test
Expand All @@ -76,12 +76,12 @@ class LocalConnectionTest {

// WHEN
// bind requested
every { context.bindService(mockIntent, any(), any()) } returns true
every { context.bindService(mockIntent!!, any(), Context.BIND_AUTO_CREATE) } returns true
connection.bind()

// THEN
// service bound
verify { context.bindService(mockIntent, any(), any()) }
verify { context.bindService(mockIntent!!, any(), Context.BIND_AUTO_CREATE) }
}

@Test
Expand Down

0 comments on commit f09c3da

Please sign in to comment.