/*
 * Copyright (C) 2009 University of Washington
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */

package org.odk.collect.android.views;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import org.commcare.dalvik.BuildConfig;
import org.commcare.dalvik.R;
import org.odk.collect.android.logic.HierarchyElement;

public class HierarchyElementView extends RelativeLayout {
    public static final String TAG = HierarchyElementView.class.getSimpleName();

    private TextView mPrimaryTextView;
    private TextView mSecondaryTextView;
    private ImageView mIcon;


    public HierarchyElementView(Context context, HierarchyElement it) {
        super(context);

        RelativeLayout layout = (RelativeLayout) inflate(context, R.layout.hierarchy_element_view, null);

        layout.setBackgroundColor(it.getColor());

        mPrimaryTextView = ((TextView)layout.findViewById(R.id.hev_primary_text));
        mPrimaryTextView.setText(it.getPrimaryText());
        mSecondaryTextView = ((TextView)layout.findViewById(R.id.hev_secondary_text));
        mSecondaryTextView.setText(it.getSecondaryText());
        mIcon = ((ImageView)layout.findViewById(R.id.hev_icon));
        mIcon.setImageDrawable(it.getIcon());

        addView(layout);

        if (BuildConfig.DEBUG) {
            Log.i(TAG, "Type of HEV (" + hashCode() + ") is " + it.getType());
            Log.i(TAG, "Icon of HEV (" + hashCode() + ") is " + (it.getIcon() == null ? "null" : it.getIcon().toString()));
        }
    }


    public void setPrimaryText(String text) {
        mPrimaryTextView.setText(text);
    }


    public void setSecondaryText(String text) {
        mSecondaryTextView.setText(text);
    }


    public void setIcon(Drawable icon) {
        mIcon.setImageDrawable(icon);
    }


    public void setColor(int color) {
        setBackgroundColor(color);
    }


    public void showSecondary(boolean bool) {
        if (bool) {
            mSecondaryTextView.setVisibility(VISIBLE);
            setMinimumHeight(dipToPx(64));

        } else {
            mSecondaryTextView.setVisibility(GONE);
            setMinimumHeight(dipToPx(32));

        }
    }
    
    public int dipToPx(int dip) {
        return (int) (dip * getResources().getDisplayMetrics().density + 0.5f);
    }

}

@@ -1,610 +1,4 @@
-/*%0A * Copyright (C) 2009 University of Washington%0A * %0A * Licensed under the Apache License, Version 2.0 (the %22License%22); you may not use this file except%0A * in compliance with the License. You may obtain a copy of the License at%0A * %0A * http://www.apache.org/licenses/LICENSE-2.0%0A * %0A * Unless required by applicable law or agreed to in writing, software distributed under the License%0A * is distributed on an %22AS IS%22 BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express%0A * or implied. See the License for the specific language governing permissions and limitations under%0A * the License.%0A */%0A%0A
 pack
@@ -112,33 +112,8 @@
 le;%0A
-import android.util.Log;%0A
 impo
@@ -216,48 +216,8 @@
 w;%0A%0A
-import org.commcare.dalvik.BuildConfig;%0A
 impo
@@ -366,96 +366,20 @@
    p
-ublic static final String TAG = HierarchyElementView.class.getSimpleName();%0A%0A    p
 rivate
+ final
  Tex
@@ -414,16 +414,22 @@
 private 
+final 
 TextView
@@ -461,16 +461,22 @@
 private 
+final 
 ImageVie
@@ -485,17 +485,16 @@
 mIcon;%0A%0A
-%0A
     publ
@@ -630,17 +630,16 @@
 eLayout)
- 
 inflate(
@@ -1163,255 +1163,8 @@
 ut);
-%0A%0A        if (BuildConfig.DEBUG) %7B%0A            Log.i(TAG, %22Type of HEV (%22 + hashCode() + %22) is %22 + it.getType());%0A            Log.i(TAG, %22Icon of HEV (%22 + hashCode() + %22) is %22 + (it.getIcon() == null ? %22null%22 : it.getIcon().toString()));%0A        %7D
 %0A   
@@ -1253,33 +1253,32 @@
 t(text);%0A    %7D%0A%0A
-%0A
     public void 
@@ -1350,33 +1350,32 @@
 t(text);%0A    %7D%0A%0A
-%0A
     public void 
@@ -1436,33 +1436,32 @@
 e(icon);%0A    %7D%0A%0A
-%0A
     public void 
@@ -1516,33 +1516,32 @@
 (color);%0A    %7D%0A%0A
-%0A
     public void 
@@ -1684,25 +1684,24 @@
 pToPx(64));%0A
-%0A
         %7D el
@@ -1796,25 +1796,24 @@
 pToPx(32));%0A
-%0A
         %7D%0A  
@@ -1820,23 +1820,20 @@
   %7D%0A
-    
 %0A    p
-ublic
+rivate
  int
@@ -1872,17 +1872,16 @@
 rn (int)
- 
 (dip * g
@@ -1937,11 +1937,10 @@
 ;%0A    %7D%0A
-%0A
 %7D%0A

Remove debug logging, linting, whitespace