Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fdd2507e authored by jruesga's avatar jruesga
Browse files

Not restrict MessageProgressDialog to number progress

This allow use the MessageProgressDialog as a message progress (xe. for
use on copy or move operations with filename progress)
parent 1a0a6ee5
Loading
Loading
Loading
Loading
+23 −5
Original line number Diff line number Diff line
@@ -559,8 +559,11 @@ public class SearchActivity extends Activity
                    SearchActivity.this.mDialog =
                            new MessageProgressDialog(
                                    SearchActivity.this,
                                    R.drawable.ic_holo_light_search, R.string.searching,
                                    label, R.plurals.search_found_items);
                                    R.drawable.ic_holo_light_search, R.string.searching, label);
                    // Initialize the 
                    setProgressMsg(0);

                    // Set the cancel listener
                    SearchActivity.this.mDialog.setOnCancelListener(
                            new MessageProgressDialog.OnCancelListener() {
                                @Override
@@ -1033,8 +1036,8 @@ public class SearchActivity extends Activity
            @Override
            public void run() {
                if (SearchActivity.this.mDialog != null) {
                    SearchActivity.this.mDialog.setProgress(
                            SearchActivity.this.mResultList.size());
                    int progress = SearchActivity.this.mResultList.size();
                    setProgressMsg(progress);
                }
            }
        });
@@ -1083,5 +1086,20 @@ public class SearchActivity extends Activity
        parcel.setSearchQuery(this.mQuery);
        return parcel;
    }

    /**
     * Method that set the progress of the search
     * 
     * @param progress The progress
     * @hide
     */
    void setProgressMsg(int progress) {
        String msg = 
                getResources().getQuantityString(
                        R.plurals.search_found_items,
                        progress,
                        Integer.valueOf(progress));
        SearchActivity.this.mDialog.setProgress(msg);
    }
}
+6 −21
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package com.cyanogenmod.explorer.ui.dialogs;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.Resources;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.TextView;
@@ -51,7 +50,6 @@ public class MessageProgressDialog implements DialogInterface.OnClickListener {
    final Context mContext;
    private final AlertDialog mDialog;
    private final TextView mProgress;
    private final int mProgressResourceId;
    /**
     * @hide
     */
@@ -65,13 +63,11 @@ public class MessageProgressDialog implements DialogInterface.OnClickListener {
     * @param iconResourceId The icon dialog resource identifier
     * @param titleResourceId The title dialog resource identifier
     * @param labelResourceId The label resource identifier
     * @param progressResourceId The message resource identifier
     */
    public MessageProgressDialog(
            Context context, int iconResourceId, int titleResourceId,
            int labelResourceId, int progressResourceId) {
            Context context, int iconResourceId, int titleResourceId, int labelResourceId) {
        this(context, iconResourceId, titleResourceId,
                context.getResources().getString(labelResourceId), progressResourceId);
                context.getResources().getString(labelResourceId));
    }

    /**
@@ -82,19 +78,14 @@ public class MessageProgressDialog implements DialogInterface.OnClickListener {
     * @param iconResourceId The icon dialog resource identifier
     * @param titleResourceId The title dialog resource identifier
     * @param labelMsg The label message
     * @param progressResourceId The message resource identifier
     */
    public MessageProgressDialog(
            Context context, int iconResourceId, int titleResourceId,
            String labelMsg, int progressResourceId) {
            Context context, int iconResourceId, int titleResourceId, String labelMsg) {
        super();

        //Save the context
        this.mContext = context;

        //Saved progress message id
        this.mProgressResourceId = progressResourceId;

        //Create the layout
        LayoutInflater li =
                (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@@ -126,9 +117,8 @@ public class MessageProgressDialog implements DialogInterface.OnClickListener {
            }
        });


        //Initialize the progress
        setProgress(0);
        this.mProgress.setText(null);
    }

    /**
@@ -145,13 +135,8 @@ public class MessageProgressDialog implements DialogInterface.OnClickListener {
     *
     * @param progress The progress of progress of the action
     */
    public void setProgress(int progress) {
        Resources res = this.mContext.getResources();
        this.mProgress.setText(
                res.getQuantityString(
                        this.mProgressResourceId,
                        progress,
                        Integer.valueOf(progress)));
    public void setProgress(String progress) {
        this.mProgress.setText(progress);
    }

    /**