1 /* ownCloud Android client application
2 * Copyright (C) 2011 Bartek Przybylski
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package eu
.alefzero
.owncloud
.ui
.fragment
;
20 import java
.util
.LinkedList
;
21 import java
.util
.Stack
;
23 import eu
.alefzero
.owncloud
.R
;
24 import eu
.alefzero
.owncloud
.R
.drawable
;
26 import android
.content
.Context
;
27 import android
.util
.AttributeSet
;
28 import android
.widget
.HorizontalScrollView
;
29 import android
.widget
.ImageView
;
30 import android
.widget
.LinearLayout
;
31 import android
.widget
.ScrollView
;
32 import android
.widget
.TextView
;
35 * Part of the ActionBar Layout
36 * @author Bartek Przybylski
39 public class PathLayout
extends LinearLayout
{
41 private LinkedList
<String
> paths
;
42 ScrollView internalScroll
;
45 public PathLayout(Context context
) {
50 public PathLayout(Context context
, AttributeSet attrs
) {
51 super(context
, attrs
);
56 if (paths
.size() == 0) {
59 int start
= paths
.size()*2-2;
61 if (paths
.size() == 1) {
65 view
.removeViews(start
, count
);
66 return paths
.removeLast();
69 public void addPath(String path
) {
70 for (String s
: path
.split("/")) if (s
.length() != 0) push(s
);
73 public void push(String path
) {
74 // its weird that we cannot declare static imgView as path separator
75 if (paths
.size() != 0) {
76 ImageView iv
= new ImageView(getContext());
77 iv
.setImageDrawable(getResources().getDrawable(R
.drawable
.breadcrumb
));
78 iv
.setPadding(2, 0, 2, 0);
81 TextView tv
= new TextView(getContext());
82 tv
.setLayoutParams(getLayoutParams());
85 HorizontalScrollView hsv
= (HorizontalScrollView
) internalScroll
.getChildAt(0);
86 hsv
.smoothScrollTo(hsv
.getMaxScrollAmount()*2, 0);
90 public String
peek() {
94 public String
getFullPath() {
95 String ret
= new String();
96 for (int i
= 0; i
< paths
.size(); i
++) {
97 ret
+= "/" + paths
.get(i
);
102 private void initialize() {
103 paths
= new LinkedList
<String
>();
104 internalScroll
= new ScrollView(getContext());
105 internalScroll
.setFillViewport(true
);
106 HorizontalScrollView hsv
= new HorizontalScrollView(getContext());
107 hsv
.setSmoothScrollingEnabled(true
);
108 internalScroll
.addView(hsv
);
109 view
= new LinearLayout(getContext());
110 addView(internalScroll
);
112 ImageView iv
= new ImageView(getContext());
113 iv
.setImageDrawable(getResources().getDrawable(R
.drawable
.breadcrumb
));