|
4 | 4 |
|
5 | 5 | import android.content.ContentResolver;
|
6 | 6 | import android.net.Uri;
|
| 7 | +import android.provider.ContactsContract; |
7 | 8 | import android.util.Log;
|
8 | 9 | import android.view.LayoutInflater;
|
9 | 10 | import android.view.View;
|
@@ -32,7 +33,7 @@ public class TilePageBuilder {
|
32 | 33 | { 0, 0, 100, 100 }
|
33 | 34 | },
|
34 | 35 | {
|
35 |
| - // 2 V (1 small) |
| 36 | + // 2 V (1 small) -> title style |
36 | 37 | { 0, 0, 100, 80 },
|
37 | 38 | { 0, 80, 100, 100 }
|
38 | 39 | },
|
@@ -278,14 +279,38 @@ public void applyStyle(int style, Page page) {
|
278 | 279 | }
|
279 | 280 |
|
280 | 281 | public int getDefaultStyle(Page page) {
|
281 |
| - int defStyle=-1; |
282 |
| - for (int i=0;i<getPageStyleMap().length;i++) { |
283 |
| - int visibleElements = 0; |
284 |
| - for (Element element: page.getElements()) { |
285 |
| - if ((element instanceof ImageElement) || (element instanceof TextElement)) { |
286 |
| - visibleElements += 1; |
| 282 | + int visibleElements = 0; |
| 283 | + boolean hasTextElement = false; |
| 284 | + boolean areAllPortrait = true; |
| 285 | + for (Element element: page.getElements()) { |
| 286 | + if ((element instanceof ImageElement) || (element instanceof TextElement) || (element instanceof VideoElement)) { |
| 287 | + visibleElements += 1; |
| 288 | + } |
| 289 | + if (element instanceof TextElement) { |
| 290 | + hasTextElement = true; |
| 291 | + } |
| 292 | + if (element instanceof ImageElement) { |
| 293 | + if (!Utils.isImagePortrait((ImageElement)element)) { |
| 294 | + areAllPortrait = false; |
287 | 295 | }
|
288 | 296 | }
|
| 297 | + } |
| 298 | + //for 2 elements |
| 299 | + if (visibleElements == 2) { |
| 300 | + //if text, apply title style |
| 301 | + if (hasTextElement) { |
| 302 | + return 1; |
| 303 | + } |
| 304 | + //if images, test if portrait or landscape |
| 305 | + if (areAllPortrait) { |
| 306 | + return 3; |
| 307 | + } else { |
| 308 | + return 2; |
| 309 | + } |
| 310 | + } |
| 311 | + //generic : choose first matching style in list |
| 312 | + int defStyle=-1; |
| 313 | + for (int i=0;i<getPageStyleMap().length;i++) { |
289 | 314 | if (getPageStyleMap()[i].length == visibleElements) {
|
290 | 315 | defStyle = i;
|
291 | 316 | break;
|
|
0 commit comments