Commits

Matjaž Črnko committed 1414bd7

Added a preference for newly added quota indicator.

Comments (0)

Files changed (2)

res/layout/preferences.xml

                 <CheckBoxPreference
                         android:title="Osveži ob odprtju"
                         android:defaultValue="false"
-                        android:summary="Osveži podatke vsakič, ko se aplikacija prikaže"
+                        android:summary="Osveži podatke ob odprtju aplikacije"
                         android:key="osvezi_ob_zagonu" />
+                <CheckBoxPreference
+                        android:title="Grafično prikaži porabo"
+                        android:defaultValue="true"
+                        android:summary="Pri zakupljenih količinah grafično prikaži porabo s sivim ozadjem"
+                        android:key="zakupljene_graficni_prikaz" />
 		</PreferenceCategory>
 		<PreferenceCategory
                 android:title="Obnašanje widgeta">

src/com/jinzo/mporaba/ItemAdapter.java

 import java.util.ArrayList;
 
 import android.content.Context;
+import android.content.SharedPreferences;
 import android.graphics.Color;
+import android.preference.PreferenceManager;
 import android.view.Display;
 import android.view.LayoutInflater;
 import android.view.View;
     public View getView(int position, View convertView, ViewGroup parent) {
             View v = convertView;
             int qindicatorWidth = 0;
+            SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this.pContext);
+            boolean display_quota_indicator = preferences.getBoolean("zakupljene_graficni_prikaz", true);	
+            		
             if (v == null) {
                 LayoutInflater vi = (LayoutInflater)pContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                 v = vi.inflate(R.layout.row, null);
                       }
                     if(bt != null){
                     	if(o.isPrepaid()) {
-                    		qindicatorWidth = getQuotaIndicatorWidth(o.getUsed(), o.getAvailable());
+                    		if (display_quota_indicator) {
+                    			qindicatorWidth = getQuotaIndicatorWidth(o.getUsed(), o.getAvailable());
+                    		}
                     		bt.setText("Porabili ste "+ o.getUsed() +" " + o.getUnit() + " in ostalo vam je še " + o.getAvailable() + " " + o.getUnit());
                     	} else {
                     		bt.setText(o.getUsed() +" "+ o.getUnit());
                     	}
                     }
             }
-            View quotaIndicator = v.findViewById(R.id.quota_indicator);
-            ViewGroup.LayoutParams lp = quotaIndicator.getLayoutParams();
-            lp.width = qindicatorWidth;
-            quotaIndicator.setLayoutParams(lp);
-            quotaIndicator.setBackgroundColor(getQuotaIndicatorBackgroundColor(qindicatorWidth));
+            if (display_quota_indicator) {
+            	View quotaIndicator = v.findViewById(R.id.quota_indicator);
+            	ViewGroup.LayoutParams lp = quotaIndicator.getLayoutParams();
+            	lp.width = qindicatorWidth;
+            	quotaIndicator.setLayoutParams(lp);
+            	quotaIndicator.setBackgroundColor(getQuotaIndicatorBackgroundColor(qindicatorWidth));
+            }
             return v;
     }
 }