├── .gitignore
├── README.md
├── example
├── AndroidManifest.xml
├── TouchGallery.iml
├── assets
│ ├── 1.jpg
│ ├── 2.jpg
│ ├── 3.jpg
│ ├── 4.jpg
│ └── 5.jpg
├── lint.xml
├── project.properties
├── res
│ ├── drawable
│ │ └── icon.png
│ ├── layout
│ │ ├── activity_main.xml
│ │ └── main.xml
│ ├── menu
│ │ └── activity_main.xml
│ └── values
│ │ └── strings.xml
└── src
│ └── ru
│ └── truba
│ └── touchgallery
│ ├── GalleryFileActivity.java
│ ├── GalleryUrlActivity.java
│ └── MainActivity.java
└── library
├── AndroidManifest.xml
├── README.md
├── ant.properties
├── build.xml
├── libs
└── android-support-v4.jar
├── pom.xml
├── proguard-project.txt
├── project.properties
├── res
├── drawable-hdpi
│ ├── ic_launcher.png
│ └── no_photo.png
├── drawable-ldpi
│ ├── ic_launcher.png
│ └── no_photo.png
├── drawable-mdpi
│ ├── ic_launcher.png
│ └── no_photo.png
├── drawable-xhdpi
│ ├── ic_launcher.png
│ └── no_photo.png
├── layout
│ └── main.xml
└── values
│ └── strings.xml
└── src
└── ru
└── truba
└── touchgallery
├── GalleryWidget
├── BasePagerAdapter.java
├── FilePagerAdapter.java
├── GalleryViewPager.java
├── InfinityFilePagerAdapter.java
├── InfinityUrlAdapter.java
└── UrlPagerAdapter.java
└── TouchView
├── EclairMotionEvent.java
├── FileTouchImageView.java
├── InputStreamWrapper.java
├── TouchImageView.java
├── UrlTouchImageView.java
└── WrapMotionEvent.java
/.gitignore:
--------------------------------------------------------------------------------
1 | #################
2 | ## Eclipse
3 | #################
4 |
5 | *.pydevproject
6 | .project
7 | .metadata
8 | bin/
9 | tmp/
10 | *.tmp
11 | *.bak
12 | *.swp
13 | *~.nib
14 | local.properties
15 | .classpath
16 | .settings/
17 | .loadpath
18 |
19 | # External tool builders
20 | .externalToolBuilders/
21 |
22 | # Locally stored "Eclipse launch configurations"
23 | *.launch
24 |
25 | # CDT-specific
26 | .cproject
27 |
28 | # PDT-specific
29 | .buildpath
30 |
31 |
32 | #################
33 | ## IntelliJ IDEA
34 | #################
35 |
36 | *.iml
37 |
38 | #################
39 | ## Visual Studio
40 | #################
41 |
42 | ## Ignore Visual Studio temporary files, build results, and
43 | ## files generated by popular Visual Studio add-ons.
44 |
45 | # User-specific files
46 | *.suo
47 | *.user
48 | *.sln.docstates
49 |
50 | # Build results
51 | [Dd]ebug/
52 | [Rr]elease/
53 | *_i.c
54 | *_p.c
55 | *.ilk
56 | *.meta
57 | *.obj
58 | *.pch
59 | *.pdb
60 | *.pgc
61 | *.pgd
62 | *.rsp
63 | *.sbr
64 | *.tlb
65 | *.tli
66 | *.tlh
67 | *.tmp
68 | *.vspscc
69 | .builds
70 | *.dotCover
71 |
72 | ## TODO: If you have NuGet Package Restore enabled, uncomment this
73 | #packages/
74 |
75 | # Visual C++ cache files
76 | ipch/
77 | *.aps
78 | *.ncb
79 | *.opensdf
80 | *.sdf
81 |
82 | # Visual Studio profiler
83 | *.psess
84 | *.vsp
85 |
86 | # ReSharper is a .NET coding add-in
87 | _ReSharper*
88 |
89 | # Installshield output folder
90 | [Ee]xpress
91 |
92 | # DocProject is a documentation generator add-in
93 | DocProject/buildhelp/
94 | DocProject/Help/*.HxT
95 | DocProject/Help/*.HxC
96 | DocProject/Help/*.hhc
97 | DocProject/Help/*.hhk
98 | DocProject/Help/*.hhp
99 | DocProject/Help/Html2
100 | DocProject/Help/html
101 |
102 | # Click-Once directory
103 | publish
104 |
105 | # Others
106 | [Bb]in
107 | [Oo]bj
108 | sql
109 | TestResults
110 | *.Cache
111 | ClientBin
112 | stylecop.*
113 | ~$*
114 | *.dbmdl
115 | Generated_Code #added for RIA/Silverlight projects
116 |
117 | # Backup & report files from converting an old project file to a newer
118 | # Visual Studio version. Backup files are not needed, because we have git ;-)
119 | _UpgradeReport_Files/
120 | Backup*/
121 | UpgradeLog*.XML
122 |
123 |
124 |
125 | ############
126 | ## Windows
127 | ############
128 |
129 | # Windows image file caches
130 | Thumbs.db
131 |
132 | # Folder config file
133 | Desktop.ini
134 |
135 |
136 | #############
137 | ## Python
138 | #############
139 |
140 | *.py[co]
141 |
142 | # Packages
143 | *.egg
144 | *.egg-info
145 | dist
146 | build
147 | eggs
148 | parts
149 | bin
150 | var
151 | sdist
152 | develop-eggs
153 | .installed.cfg
154 |
155 | # Installer logs
156 | pip-log.txt
157 |
158 | # Unit test / coverage reports
159 | .coverage
160 | .tox
161 |
162 | #Translations
163 | *.mo
164 |
165 | #Mr Developer
166 | .mr.developer.cfg
167 |
168 | # Mac crap
169 | .DS_Store
170 |
171 | #inteliji idea
172 | .idea
173 |
174 | #android
175 | gen
176 | out
177 |
178 | #project
179 | example/src/ru/truba/touchgallery/GalleryWidget
180 | example/src/ru/truba/touchgallery/TouchView
181 |
182 | bin/
183 | gen/
184 | target/
185 |
186 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Attention please!
2 | ===================
3 | This library is not supported anymore. Please, check out nice living forks!
4 | Thanks for attention.
5 |
6 |
7 | AndroidTouchGallery
8 | ===================
9 |
10 | Android widget for gallery, using viewpager. Allow pinch zoom and drag for images by url.
11 | Widget allows use it in Android > 2.0!
12 |
13 |
14 | How to use
15 | ===================
16 | 1. Make import library folder into your IDE.
17 | 2. Make sure, that AndroidTouchGallery has included in your project as library. Check project properties, and make sure checkbox "Is library" is checked.
18 | 3. Include GalleryViewPager in your layout xml or programmatically.
19 | ```
20 |
25 | ```
26 |
27 | 4. Provide one of library adapters: UrlPagerAdapter or FilePagerAdapter
28 | For example (an Activity code):
29 | ```java
30 | setContentView(R.layout.main);
31 | String[] urls = {
32 | "http://cs407831.userapi.com/v407831207/18f6/jBaVZFDhXRA.jpg",
33 | "http://cs407831.userapi.com/v4078f31207/18fe/4Tz8av5Hlvo.jpg", //special url with error
34 | "http://cs407831.userapi.com/v407831207/1906/oxoP6URjFtA.jpg",
35 | "http://cs407831.userapi.com/v407831207/190e/2Sz9A774hUc.jpg",
36 | "http://cs407831.userapi.com/v407831207/1916/Ua52RjnKqjk.jpg",
37 | "http://cs407831.userapi.com/v407831207/191e/QEQE83Ok0lQ.jpg"
38 | };
39 | List items = new ArrayList();
40 | Collections.addAll(items, urls);
41 | UrlPagerAdapter pagerAdapter = new UrlPagerAdapter(this, items);
42 | GalleryViewPager mViewPager = (GalleryViewPager)findViewById(R.id.viewer);
43 | mViewPager.setOffscreenPageLimit(3);
44 | mViewPager.setAdapter(pagerAdapter);
45 | ```
46 |
47 | 5. You can always check example if you miss something.
48 |
49 | License
50 | ===================
51 | Copyright (c) 2012-2013 Roman Truba
52 |
53 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
54 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation
55 | the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
56 | permit persons to whom the Software is furnished to do so, subject to the following conditions:
57 |
58 | The above copyright notice and this permission notice shall be included in all copies or substantial
59 | portions of the Software.
60 |
61 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
62 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
63 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
64 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
65 | THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
66 |
--------------------------------------------------------------------------------
/example/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
12 |
17 |
20 |
21 |
24 |
25 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/example/TouchGallery.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | /res-overlay
28 |
29 | true
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/example/assets/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RomanTruba/AndroidTouchGallery/f9d88cc56acf1e1e8a52130d4aa6340267b1b632/example/assets/1.jpg
--------------------------------------------------------------------------------
/example/assets/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RomanTruba/AndroidTouchGallery/f9d88cc56acf1e1e8a52130d4aa6340267b1b632/example/assets/2.jpg
--------------------------------------------------------------------------------
/example/assets/3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RomanTruba/AndroidTouchGallery/f9d88cc56acf1e1e8a52130d4aa6340267b1b632/example/assets/3.jpg
--------------------------------------------------------------------------------
/example/assets/4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RomanTruba/AndroidTouchGallery/f9d88cc56acf1e1e8a52130d4aa6340267b1b632/example/assets/4.jpg
--------------------------------------------------------------------------------
/example/assets/5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RomanTruba/AndroidTouchGallery/f9d88cc56acf1e1e8a52130d4aa6340267b1b632/example/assets/5.jpg
--------------------------------------------------------------------------------
/example/lint.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/example/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by IntelliJ IDEA
2 | # Project target.
3 | target=android-17
4 | android.library.reference.1=../library
5 |
--------------------------------------------------------------------------------
/example/res/drawable/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RomanTruba/AndroidTouchGallery/f9d88cc56acf1e1e8a52130d4aa6340267b1b632/example/res/drawable/icon.png
--------------------------------------------------------------------------------
/example/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
13 |
14 |
--------------------------------------------------------------------------------
/example/res/layout/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
11 |
--------------------------------------------------------------------------------
/example/res/menu/activity_main.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/example/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Touch Gallery
5 | Hello world!
6 | Settings
7 | Main Activity
8 |
9 |
--------------------------------------------------------------------------------
/example/src/ru/truba/touchgallery/GalleryFileActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2012 Roman Truba
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation
6 | the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 |
9 | The above copyright notice and this permission notice shall be included in all copies or substantial
10 | portions of the Software.
11 |
12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
13 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
14 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
15 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
16 | THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 | */
18 | package ru.truba.touchgallery;
19 |
20 | import android.app.Activity;
21 | import android.os.Bundle;
22 | import android.widget.Toast;
23 | import ru.truba.touchgallery.GalleryWidget.FilePagerAdapter;
24 | import ru.truba.touchgallery.GalleryWidget.GalleryViewPager;
25 | import ru.truba.touchgallery.GalleryWidget.BasePagerAdapter.OnItemChangeListener;
26 |
27 | import java.io.File;
28 | import java.io.FileOutputStream;
29 | import java.io.IOException;
30 | import java.io.InputStream;
31 | import java.io.OutputStream;
32 | import java.util.ArrayList;
33 | import java.util.List;
34 |
35 | public class GalleryFileActivity extends Activity {
36 |
37 | private GalleryViewPager mViewPager;
38 | public void onCreate(Bundle savedInstanceState) {
39 | super.onCreate(savedInstanceState);
40 | setContentView(R.layout.main);
41 |
42 | String[] urls = null;
43 | List items = new ArrayList();
44 | try {
45 | urls = getAssets().list("");
46 |
47 | for (String filename : urls)
48 | {
49 | if (filename.matches(".+\\.jpg"))
50 | {
51 | String path = getFilesDir() + "/" + filename;
52 | copy(getAssets().open(filename), new File(path) );
53 | items.add(path);
54 | }
55 | }
56 | } catch (IOException e) {
57 | e.printStackTrace();
58 | }
59 |
60 | FilePagerAdapter pagerAdapter = new FilePagerAdapter(this, items);
61 | pagerAdapter.setOnItemChangeListener(new OnItemChangeListener()
62 | {
63 | @Override
64 | public void onItemChange(int currentPosition)
65 | {
66 | Toast.makeText(GalleryFileActivity.this, "Current item is " + currentPosition, Toast.LENGTH_SHORT).show();
67 | }
68 | });
69 |
70 | mViewPager = (GalleryViewPager)findViewById(R.id.viewer);
71 | mViewPager.setOffscreenPageLimit(3);
72 | mViewPager.setAdapter(pagerAdapter);
73 | }
74 | public void copy(InputStream in, File dst) throws IOException {
75 |
76 | OutputStream out = new FileOutputStream(dst);
77 |
78 | // Transfer bytes from in to out
79 | byte[] buf = new byte[1024];
80 | int len;
81 | while ((len = in.read(buf)) > 0) {
82 | out.write(buf, 0, len);
83 | }
84 | in.close();
85 | out.close();
86 | }
87 | }
--------------------------------------------------------------------------------
/example/src/ru/truba/touchgallery/GalleryUrlActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2012 Roman Truba
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation
6 | the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7 | permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 |
9 | The above copyright notice and this permission notice shall be included in all copies or substantial
10 | portions of the Software.
11 |
12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
13 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
14 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
15 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
16 | THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 | */
18 | package ru.truba.touchgallery;
19 |
20 | import android.app.Activity;
21 | import android.os.Bundle;
22 | import android.widget.Toast;
23 | import ru.truba.touchgallery.GalleryWidget.BasePagerAdapter.OnItemChangeListener;
24 | import ru.truba.touchgallery.GalleryWidget.GalleryViewPager;
25 | import ru.truba.touchgallery.GalleryWidget.UrlPagerAdapter;
26 |
27 | import java.util.ArrayList;
28 | import java.util.Collections;
29 | import java.util.List;
30 |
31 | public class GalleryUrlActivity extends Activity {
32 |
33 | private GalleryViewPager mViewPager;
34 | public void onCreate(Bundle savedInstanceState) {
35 | super.onCreate(savedInstanceState);
36 | setContentView(R.layout.main);
37 | String[] urls = {
38 | "http://cs407831.userapi.com/v407831207/18f6/jBaVZFDhXRA.jpg",
39 | "http://cs407831.userapi.com/v4078f31207/18fe/4Tz8av5Hlvo.jpg",
40 | "http://cs407831.userapi.com/v407831207/1906/oxoP6URjFtA.jpg",
41 | "http://cs407831.userapi.com/v407831207/190e/2Sz9A774hUc.jpg",
42 | "http://cs407831.userapi.com/v407831207/1916/Ua52RjnKqjk.jpg",
43 | "http://cs407831.userapi.com/v407831207/191e/QEQE83Ok0lQ.jpg"
44 | };
45 | List items = new ArrayList();
46 | Collections.addAll(items, urls);
47 |
48 | UrlPagerAdapter pagerAdapter = new UrlPagerAdapter(this, items);
49 | pagerAdapter.setOnItemChangeListener(new OnItemChangeListener()
50 | {
51 | @Override
52 | public void onItemChange(int currentPosition)
53 | {
54 | Toast.makeText(GalleryUrlActivity.this, "Current item is " + currentPosition, Toast.LENGTH_SHORT).show();
55 | }
56 | });
57 |
58 | mViewPager = (GalleryViewPager)findViewById(R.id.viewer);
59 | mViewPager.setOffscreenPageLimit(3);
60 | mViewPager.setAdapter(pagerAdapter);
61 |
62 | }
63 |
64 | }
--------------------------------------------------------------------------------
/example/src/ru/truba/touchgallery/MainActivity.java:
--------------------------------------------------------------------------------
1 | package ru.truba.touchgallery;
2 |
3 | import java.util.ArrayList;
4 | import java.util.HashMap;
5 | import java.util.List;
6 | import java.util.Map;
7 |
8 | import android.os.Bundle;
9 | import android.app.ListActivity;
10 | import android.content.Intent;
11 | import android.view.View;
12 | import android.widget.ListAdapter;
13 | import android.widget.ListView;
14 | import android.widget.SimpleAdapter;
15 |
16 | public class MainActivity extends ListActivity {
17 |
18 | public static final String TITLE = "title";
19 | public static final String SUBTITLE = "subtitle";
20 |
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | // setContentView(R.layout.activity_main);
25 |
26 | setListAdapter(createAdapter());
27 | }
28 |
29 | protected Map createElement(String title, String subtitle)
30 | {
31 | Map result = new HashMap();
32 | result.put(TITLE, title);
33 | result.put(SUBTITLE, subtitle);
34 | return result;
35 | }
36 | public List