Skip to content

Commit

Permalink
Use M3
Browse files Browse the repository at this point in the history
Signed-off-by: alperozturk <[email protected]>
  • Loading branch information
alperozturk96 authored and AndyScherzinger committed Oct 30, 2023
1 parent 8c78214 commit 8ec09c7
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 56 deletions.
95 changes: 43 additions & 52 deletions app/src/main/java/com/owncloud/android/ui/dialog/LoadingDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,73 +16,64 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.owncloud.android.ui.dialog;
package com.owncloud.android.ui.dialog

import android.app.Dialog;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.ProgressBar;
import android.widget.TextView;
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

import com.nextcloud.client.di.Injectable;
import com.owncloud.android.R;
import com.owncloud.android.utils.theme.ViewThemeUtils;
class LoadingDialog : DialogFragment(), Injectable {

import javax.inject.Inject;
@JvmField
@Inject
var viewThemeUtils: ViewThemeUtils? = null

import androidx.annotation.NonNull;
import androidx.fragment.app.DialogFragment;
private var mMessage: String? = null
private lateinit var binding: LoadingDialogBinding

public class LoadingDialog extends DialogFragment implements Injectable {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

@Inject ViewThemeUtils viewThemeUtils;
private String mMessage;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRetainInstance(true);
setCancelable(false);
}

public static LoadingDialog newInstance(String message) {
LoadingDialog loadingDialog = new LoadingDialog();
loadingDialog.mMessage = message;
return loadingDialog;
retainInstance = true
isCancelable = false
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Create a view by inflating desired layout
View v = inflater.inflate(R.layout.loading_dialog, container, false);
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = LoadingDialogBinding.inflate(inflater, container, false)
binding.loadingText.text = mMessage

// set value
TextView tv = v.findViewById(R.id.loadingText);
tv.setText(mMessage);
val loadingDrawable = binding.loadingBar.indeterminateDrawable
if (loadingDrawable != null) {
viewThemeUtils?.platform?.tintDrawable(requireContext(), loadingDrawable)
}

// set progress wheel color
ProgressBar progressBar = v.findViewById(R.id.loadingBar);
viewThemeUtils.platform.tintDrawable(requireContext(), progressBar.getIndeterminateDrawable());
viewThemeUtils?.platform?.colorViewBackground(binding.loadingLayout, ColorRole.SURFACE_VARIANT)

return v;
return binding.root
}

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = super.onCreateDialog(savedInstanceState);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
return dialog;
override fun onDestroyView() {
if (dialog != null && retainInstance) {
dialog!!.setDismissMessage(null)
}

super.onDestroyView()
}

@Override
public void onDestroyView() {
if (getDialog() != null && getRetainInstance()) {
getDialog().setDismissMessage(null);
companion object {

@JvmStatic
fun newInstance(message: String?): LoadingDialog {
val loadingDialog = LoadingDialog()
loadingDialog.mMessage = message
return loadingDialog
}
super.onDestroyView();
}
}
8 changes: 4 additions & 4 deletions app/src/main/res/layout/loading_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@
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"
android:orientation="horizontal"
android:padding="@dimen/standard_padding">

<ProgressBar
<com.google.android.material.progressindicator.CircularProgressIndicator
android:id="@+id/loadingBar"
style="?android:attr/progressBarStyle"
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

0 comments on commit 8ec09c7

Please sign in to comment.