Skip to content

Commit ed15c42

Browse files
committed
fix image preview
Signed-off-by: alperozturk <[email protected]>
1 parent 008e270 commit ed15c42

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

app/src/main/java/com/owncloud/android/ui/activity/ToolbarActivity.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,6 @@ private String getActionBarTitleFromFile(OCFile file) {
215215
}
216216

217217
protected void updateActionBarTitleAndHomeButton(OCFile file) {
218-
if (mAppBar == null) {
219-
return;
220-
}
221-
222218
final OCFileDepth currentDirDepth = getCurrentDirDepth();
223219
final boolean isRoot = isRoot(file) || currentDirDepth == OCFileDepth.Root;
224220
final String title = getActionBarTitle(file, isRoot);
@@ -228,7 +224,10 @@ protected void updateActionBarTitleAndHomeButton(OCFile file) {
228224
final boolean canShowSearchBar = (isHomeSearchToolbarShow && isRoot && isToolbarStyleSearch);
229225

230226
showHomeSearchToolbar(canShowSearchBar);
231-
mSearchText.setText(getString(R.string.appbar_search_in, title));
227+
228+
if (mSearchText != null) {
229+
mSearchText.setText(getString(R.string.appbar_search_in, title));
230+
}
232231

233232
final var actionBar = getSupportActionBar();
234233
if (actionBar != null) {
@@ -237,7 +236,7 @@ protected void updateActionBarTitleAndHomeButton(OCFile file) {
237236
}
238237

239238
protected void updateActionBarForFile(@Nullable OCFile file) {
240-
if (mAppBar == null || file == null) {
239+
if (file == null) {
241240
return;
242241
}
243242

@@ -265,7 +264,12 @@ public void hideSearchView(OCFile chosenFile) {
265264

266265
@SuppressLint("PrivateResource")
267266
private void showHomeSearchToolbar(boolean isShow) {
267+
if (mAppBar == null) {
268+
return;
269+
}
270+
268271
viewThemeUtils.material.themeToolbar(mToolbar);
272+
269273
if (isShow) {
270274
viewThemeUtils.platform.resetStatusBar(this);
271275
mAppBar.setStateListAnimator(AnimatorInflater.loadStateListAnimator(mAppBar.getContext(),

app/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.kt

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import android.content.BroadcastReceiver
1010
import android.content.Context
1111
import android.content.Intent
1212
import android.content.IntentFilter
13+
import android.graphics.drawable.ColorDrawable
1314
import android.os.Bundle
1415
import android.view.MenuItem
1516
import android.view.View
1617
import androidx.activity.OnBackPressedCallback
17-
import androidx.appcompat.app.ActionBar
1818
import androidx.core.content.ContextCompat
1919
import androidx.drawerlayout.widget.DrawerLayout
2020
import androidx.localbroadcastmanager.content.LocalBroadcastManager
@@ -82,21 +82,17 @@ class PreviewImageActivity :
8282
@Inject
8383
lateinit var localBroadcastManager: LocalBroadcastManager
8484

85-
private var actionBar: ActionBar? = null
86-
8785
override fun onCreate(savedInstanceState: Bundle?) {
8886
super.onCreate(savedInstanceState)
8987

90-
actionBar = supportActionBar
91-
9288
if (savedInstanceState != null &&
9389
!savedInstanceState.getBoolean(
9490
KEY_SYSTEM_VISIBLE,
9591
true
9692
) &&
97-
actionBar != null
93+
supportActionBar != null
9894
) {
99-
actionBar?.hide()
95+
supportActionBar?.hide()
10096
}
10197

10298
setContentView(R.layout.preview_image_activity)
@@ -106,11 +102,14 @@ class PreviewImageActivity :
106102
setupDrawer()
107103

108104
val chosenFile = intent.getParcelableArgument(EXTRA_FILE, OCFile::class.java)
109-
updateActionBarTitleAndHomeButton(chosenFile)
110105

111-
if (actionBar != null) {
112-
viewThemeUtils.files.setWhiteBackButton(this, actionBar!!)
113-
actionBar?.setDisplayHomeAsUpEnabled(true)
106+
supportActionBar?.let {
107+
updateActionBarTitleAndHomeButton(chosenFile)
108+
viewThemeUtils.files.setWhiteBackButton(this, it)
109+
it.setDisplayHomeAsUpEnabled(true)
110+
it.setBackgroundDrawable(
111+
ColorDrawable(ContextCompat.getColor(this, R.color.black))
112+
)
114113
}
115114

116115
fullScreenAnchorView = window.decorView
@@ -147,14 +146,10 @@ class PreviewImageActivity :
147146
}
148147

149148
fun toggleActionBarVisibility(hide: Boolean) {
150-
if (actionBar == null) {
151-
return
152-
}
153-
154149
if (hide) {
155-
actionBar?.hide()
150+
supportActionBar?.hide()
156151
} else {
157-
actionBar?.show()
152+
supportActionBar?.show()
158153
}
159154
}
160155

0 commit comments

Comments
 (0)