// The stackoverflow post:
//
// http://stackoverflow.com/a/11670016/1160711
//
// described this code for getting rid of the M/N number display in the
// progress bar on older versions of the android api. I'm giving it a
// whirl... [It works!]

package my.lan.zooty.upwithphp;

import android.app.ProgressDialog;
import android.util.Log;
import android.content.Context;
import android.os.Bundle;
import java.lang.reflect.Method;
import android.widget.TextView;
import java.lang.reflect.Field;
import android.view.View;

public class ProgressWithoutNumbers extends ProgressDialog {

   String Tag="ProgressWithoutNumbers";

   public ProgressWithoutNumbers(Context context) {
      super(context);
   }

   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);

      try {
         Method method = TextView.class.getMethod("setVisibility",
               Integer.TYPE);

         Field[] fields = this.getClass().getSuperclass()
               .getDeclaredFields();

         for (Field field : fields) {
            if (field.getName().equalsIgnoreCase("mProgressNumber")) {
               field.setAccessible(true);
               TextView textView = (TextView) field.get(this);
               method.invoke(textView, View.GONE);
            }
         }
      } catch (Exception e) {
         Log.e(Tag, "Failed to make numbers invisible", e);
      }
   }
}
