package org.commcare.views.dialogs;

import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

import org.commcare.dalvik.R;

public class GeoProgressDialog extends Dialog {

    private final TextView mText;
    private final ImageView mImage;
    private final Button mAccept;
    private final Button mCancel;
    private final ProgressBar mProgress;
    private boolean locationFound;
    private final String mFoundMessage;
    private final String mSearchMessage;

    public GeoProgressDialog(Context context, String foundMessage, String searchMessage) {
        super(context);
        // back button doesn't cancel
        setCancelable(false);
        setContentView(R.layout.geo_progress);
        this.mImage = (ImageView)findViewById(R.id.geoImage);
        this.mText = (TextView)findViewById(R.id.geoText);
        this.mAccept = (Button)findViewById(R.id.geoOK);
        this.mCancel = (Button)findViewById(R.id.geoCancel);
        this.mProgress = (ProgressBar)findViewById(R.id.geoProgressBar);
        locationFound = false;
        mFoundMessage = foundMessage;
        mSearchMessage = searchMessage;
        refreshView();
    }

    public void setMessage(String txt) {
        mText.setText(txt);
    }

    public void setImage(Drawable img) {
        mImage.setImageDrawable(img);
    }

    public void setOKButton(String title, View.OnClickListener ocl) {
        mAccept.setText(title);
        mAccept.setOnClickListener(ocl);
    }

    public void setCancelButton(String title, View.OnClickListener ocl) {
        mCancel.setText(title);
        mCancel.setOnClickListener(ocl);
    }

    public void setLocationFound(boolean locationFound) {
        this.locationFound = locationFound;
        refreshView();
    }

    private void refreshView() {
        if (locationFound) {
            mImage.setVisibility(View.VISIBLE);
            mProgress.setVisibility(View.GONE);
            mCancel.setVisibility(View.GONE);
            mAccept.setVisibility(View.VISIBLE);
            this.setTitle(mFoundMessage);
        } else {
            this.setTitle(mSearchMessage);
            mImage.setVisibility(View.GONE);
            mCancel.setVisibility(View.VISIBLE);
            mAccept.setVisibility(View.GONE);
            mProgress.setVisibility(View.VISIBLE);
        }
    }


}
@@ -396,21 +396,24 @@
 extView 
-mT
+t
 ext
+View
 ;%0A    pr
@@ -434,22 +434,25 @@
 ageView 
-mI
+i
 mage
+View
 ;%0A    pr
@@ -470,23 +470,28 @@
  Button 
-mA
+a
 ccept
+Button
 ;%0A    pr
@@ -509,23 +509,28 @@
  Button 
-mC
+c
 ancel
+Button
 ;%0A    pr
@@ -553,25 +553,27 @@
 ressBar 
-mP
+p
 rogress
+Bar
 ;%0A    pr
@@ -626,17 +626,24 @@
  String 
-m
+location
 FoundMes
@@ -673,23 +673,25 @@
  String 
-mS
+s
 earch
+ing
 Message;
@@ -935,22 +935,25 @@
    this.
-mI
+i
 mage
+View
  = (Imag
@@ -1000,21 +1000,24 @@
    this.
-mT
+t
 ext
+View
  = (Text
@@ -1062,23 +1062,28 @@
    this.
-mA
+a
 ccept
+Button
  = (Butt
@@ -1124,23 +1124,28 @@
    this.
-mC
+c
 ancel
+Button
  = (Butt
@@ -1190,25 +1190,27 @@
    this.
-mP
+p
 rogress
+Bar
  = (Prog
@@ -1291,17 +1291,24 @@
         
-m
+location
 FoundMes
@@ -1336,23 +1336,25 @@
         
-mS
+s
 earch
+ing
 Message 
@@ -1453,13 +1453,16 @@
     
-mT
+t
 ext
+View
 .set
@@ -1524,30 +1524,33 @@
 ) %7B%0A        
-mI
+i
 mage
+View
 .setImageDra
@@ -1642,31 +1642,36 @@
 ) %7B%0A        
-mA
+a
 ccept
+Button
 .setText(tit
@@ -1679,31 +1679,36 @@
 e);%0A        
-mA
+a
 ccept
+Button
 .setOnClickL
@@ -1806,31 +1806,36 @@
 ) %7B%0A        
-mC
+c
 ancel
+Button
 .setText(tit
@@ -1843,31 +1843,36 @@
 e);%0A        
-mC
+c
 ancel
+Button
 .setOnClickL
@@ -2090,38 +2090,41 @@
 ) %7B%0A            
-mI
+i
 mage
+View
 .setVisibility(V
@@ -2145,33 +2145,35 @@
             
-mP
+p
 rogress
+Bar
 .setVisibili
@@ -2191,39 +2191,44 @@
 E);%0A            
-mC
+c
 ancel
+Button
 .setVisibility(V
@@ -2242,39 +2242,44 @@
 E);%0A            
-mA
+a
 ccept
+Button
 .setVisibility(V
@@ -2318,17 +2318,24 @@
 etTitle(
-m
+location
 FoundMes
@@ -2388,15 +2388,17 @@
 tle(
-mS
+s
 earch
+ing
 Mess
@@ -2419,14 +2419,17 @@
     
-mI
+i
 mage
+View
 .set
@@ -2467,15 +2467,20 @@
     
-mC
+c
 ancel
+Button
 .set
@@ -2521,15 +2521,20 @@
     
-mA
+a
 ccept
+Button
 .set
@@ -2572,17 +2572,19 @@
     
-mP
+p
 rogress
+Bar
 .set

rename member variables