Commits

Clayton Sims committed 35bc075

Cleanup and Screen Height

Comments (0)

Files changed (4)

j2me/core/src/org/javarosa/j2me/view/J2MEDisplay.java

 		
 		return alert;
 	}
+	
+
+	public static int getScreenHeight(int fallback) {
+		int staticHeight = -1;
+		int guess = de.enough.polish.ui.Display.getScreenHeight();
+		
+		//#ifdef polish.fullcanvasheight:defined
+		//#= staticHeight = ${ polish.fullcanvasheight };
+		//#elifdef polish.screenheight:defined
+		//#= staticHeight = ${ polish.screenheight };
+		//#endif
+		
+		if(guess == -1 && staticHeight == -1) {
+			return fallback;
+		} else if(guess != 1) {
+			return guess;
+		} else {
+			return staticHeight;
+		}
+	}
 
 	public static int getScreenWidth(int fallback) {
 		int staticWidth = -1;

j2me/demo-app/build.properties

 javarosa.dev.serializationtest.verbose=false
 javarosa.useloadingscreen=true
 
-javarosa.patientselect.formfactor=default
-#javarosa.patientselect.formfactor allowed values:
-#  nokia-s40: 128x160 nokia series 40 phones (6085, 3110, etc.)
-#  default: 240x320 for sun wtk emulator
-
 ### Use Default Color Phone
 #device.identifier=Generic/DefaultColorPhone
 #wtk.home=/usr/local/wtk

j2me/entity-select/src/org/javarosa/entity/model/view/EntitySelectView.java

 
 public class EntitySelectView<E extends Persistable> extends FramedForm implements HandledPItemStateListener, HandledCommandListener {
 	
-	//TODO: Capture screen height and define this based on it
-	//#ifdef javarosa.patientselect.maxrows:defined
-	//#= private static final int MAX_ROWS_ON_SCREEN = ${ javarosa.patientselect.maxrows };
-	//#else
-	private static final int MAX_ROWS_ON_SCREEN = 10;
-	//#endif
-	
-	//#ifdef javarosa.patientselect.scrollincrement:defined
-	//#= private static final int SCROLL_INCREMENT = ${ javarosa.patientselect.scrollincrement };
-	//#else
-	private static final int SCROLL_INCREMENT = 5;	
-	//#endif
+	private int MAX_ROWS_ON_SCREEN = 10;
+
+	private int SCROLL_INCREMENT = 5;	
 	
 	public static final int NEW_DISALLOWED = 0;
 	public static final int NEW_IN_LIST = 1;
         
         calculateStyles();
         
+        estimateHeights();
+        
         refresh();
 	}
 	
 		rowStyle = genStyleFromHints(entityPrototype.getStyleHints(false));
 	}
 	
+	private void estimateHeights() {
+		int screenHeight = J2MEDisplay.getScreenHeight(320);
+		
+		//This is _super_ basic based on commonly available
+		//phones. We should actually wait for things to be drawn once
+		//and then recalculate for real;
+		
+		if(screenHeight >= 300) { 
+			MAX_ROWS_ON_SCREEN = 10;
+		} else if(screenHeight >= 200) {
+			MAX_ROWS_ON_SCREEN = 6;
+		} else if(screenHeight >= 160) {
+			MAX_ROWS_ON_SCREEN = 5;
+		} else {
+			MAX_ROWS_ON_SCREEN = 4;
+		}
+		
+		
+		if(MAX_ROWS_ON_SCREEN > 5) {
+			SCROLL_INCREMENT = 5;
+		} else {
+			SCROLL_INCREMENT = 4;
+		}
+	}
+	
 	private Style genStyleFromHints(int[] hints) {
 		
 		int screenwidth = J2MEDisplay.getScreenWidth(240);

j2me/shared-resources/resources/polish.css

     text-wrap: false
 }
 
-.patselTitleRow extends patselRow {
-	background-color: #5CFFAD;
-}
-
 .patselTitleRowText{
-	/*text-wrap: false;
+	text-wrap: false;
 	font {
 		face: proportional;
 		style: bold;
 		size: small;
-		color: white;
 	}
-	*/
 }
 
 .patselTitleRowContainer extends patselRow {
-	/*
-	background-color: lighterBlue;
-	*/
+	background-color: #5CFFAD;
 }
 
 .loginTextFields {
 		border-width: 1;*/
 }
 
-
-/** ------------    Entity Select for Model Select ----------------- **/
-.modelSelectRow {
-    font-size: small;
-	//#if javarosa.patientselect.formfactor == nokia-s40
-	/** NOTE: screen width 128px **/
-	columns: 4;
-	columns-width: 30,45,50,0;
-	//#else if javarosa.patientselect.formfactor == generic-mcs
-	columns: 4;
-	columns-width: 65,30,33,0;
-	//#else 
-	columns: 4;
-	columns-width: 110,15,25,0;
-	//#endif
-}
-
-.modelSelectEvenRow extends modelSelectRow {
-	background-color: white;
-}
-
-.modelSelectOddRow extends modelSelectRow {
-	background-color:  #EEEEFF;
-}
-
-.modelSelectSelectedRow extends modelSelectRow {
-	background-color:  #FFCCCC;
-}
-
-.modelSelectTitleRow extends modelSelectRow {
-	//#if javarosa.patientselect.formfactor == nokia-s40
-	/** NOTE: screen width 128px **/
-	columns: 4;
-	columns-width: 27,40,43,18;
-	//#else if javarosa.patientselect.formfactor == generic-mcs
-	columns: 4;
-	columns-width: 60,27,23,18;
-	//#else 
-	columns: 4;
-	columns-width: 110,95,25,10;
-	//#endif
-	background-color: #5CFFAD;
-	
-}
-
-/** ------------    Entity Select for Referral Select ----------------- **/
-
-.referralSelectRow {
-    font-size: small;
-	//#if javarosa.patientselect.formfactor == nokia-s40
-	columns: 4;
-	columns-width: 25,50,35,18;
-	//#else
-	columns: 4;
-	columns-width: 50,115,50,25;
-	//#endif
-}
-
-.referralSelectTitleRow extends modelSelectRow {
-    font-size: small;
-	//#if javarosa.patientselect.formfactor == nokia-s40
-	columns: 4;
-	columns-width: 25,50,35,18;
-	//#else
-	columns: 4;
-	columns-width: 50,115,50,25;
-	//#endif
-	background-color: #5CFFAD;
-}
-
-.referralSelectEvenRow extends referralSelectRow {
-	background-color: white;
-}
-
-.referralSelectOddRow extends referralSelectRow {
-	background-color:  #EEEEFF;
-}
-
-.referralSelectSelectedRow extends referralSelectRow {
-	background-color:  #FFCCCC;
-}
 /** ------------   Popup Style   -----------------**/
 
 .patselDetailRow {