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

Use Material Design 3 For Loading Popup #12070

Merged
merged 4 commits into from
Oct 30, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
import androidx.annotation.NonNull;
import androidx.fragment.app.DialogFragment;
import androidx.test.espresso.intent.rule.IntentsTestRule;
import androidx.test.rule.GrantPermissionRule;
import kotlin.Unit;

import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
Expand All @@ -108,6 +109,9 @@ private FileDisplayActivity getFileDisplayActivity() {
return activityRule.launchActivity(intent);
}

@Rule
public GrantPermissionRule permissionRule = GrantPermissionRule.grant(
android.Manifest.permission.POST_NOTIFICATIONS);

@After
public void quitLooperIfNeeded() {
Expand Down

This file was deleted.

79 changes: 79 additions & 0 deletions app/src/main/java/com/owncloud/android/ui/dialog/LoadingDialog.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* ownCloud Android client application
*
* Copyright (C) 2015 ownCloud Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.owncloud.android.ui.dialog

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.DialogFragment
import com.nextcloud.android.common.ui.theme.utils.ColorRole
import com.nextcloud.client.di.Injectable
import com.owncloud.android.databinding.LoadingDialogBinding
import com.owncloud.android.utils.theme.ViewThemeUtils
import javax.inject.Inject

class LoadingDialog : DialogFragment(), Injectable {

@JvmField
@Inject
var viewThemeUtils: ViewThemeUtils? = null

private var mMessage: String? = null
private lateinit var binding: LoadingDialogBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

retainInstance = true
isCancelable = false
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = LoadingDialogBinding.inflate(inflater, container, false)
binding.loadingText.text = mMessage

val loadingDrawable = binding.loadingBar.indeterminateDrawable
if (loadingDrawable != null) {
viewThemeUtils?.platform?.tintDrawable(requireContext(), loadingDrawable)
}

viewThemeUtils?.platform?.colorViewBackground(binding.loadingLayout, ColorRole.SURFACE_VARIANT)

return binding.root
}

override fun onDestroyView() {
if (dialog != null && retainInstance) {
dialog?.setDismissMessage(null)
}

super.onDestroyView()
}

companion object {

@JvmStatic
fun newInstance(message: String?): LoadingDialog {
val loadingDialog = LoadingDialog()
loadingDialog.mMessage = message
return loadingDialog
}
}
}
7 changes: 4 additions & 3 deletions app/src/main/res/layout/loading_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/loadingLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand All @@ -25,14 +26,14 @@

<ProgressBar
android:id="@+id/loadingBar"
style="?android:attr/progressBarStyle"
style="@style/Widget.Material3.CircularProgressIndicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:indeterminate="true"
android:indeterminateOnly="false"/>

<TextView
<com.google.android.material.textview.MaterialTextView
android:id="@+id/loadingText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down
Loading