~humpolec-team/humpolec/UbuntuInstaller-refactor

« back to all changes in this revision

Viewing changes to src/com/canonical/ubuntu/installer/Utils.java

  • Committer: Ondrej Kubik
  • Date: 2013-12-12 02:02:35 UTC
  • Revision ID: ondrej.kubik@canonical.com-20131212020235-ipkk7w5yh248anxr
New UI with two views
added progress bars for download and install
added uninstall
several usecases improvement

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package com.canonical.ubuntuinstaller;
 
1
package com.canonical.ubuntu.installer;
2
2
 
3
3
import java.io.BufferedInputStream;
4
4
import java.io.BufferedReader;
11
11
import java.io.Reader;
12
12
import java.io.StringWriter;
13
13
import java.io.Writer;
 
14
import java.util.List;
14
15
 
15
16
import org.apache.http.HttpEntity;
16
17
import org.apache.http.HttpResponse;
21
22
import android.content.Context;
22
23
import android.content.res.AssetManager;
23
24
import android.util.Log;
 
25
import android.widget.Toast;
24
26
 
25
27
public class Utils {
26
28
 
27
29
        private final static String TAG = "Utils";
28
 
 
 
30
        private final static int SIGNATURE_SIZE = 490;
 
31
        
 
32
        
 
33
        public static void showToast(Context context, String message) {
 
34
        int duration = Toast.LENGTH_SHORT;
 
35
        Toast toast = Toast.makeText(context, message, duration);
 
36
        toast.show();
 
37
    }
 
38
        
29
39
        public static String httpDownload(String url) { // return null as error happens
30
40
                HttpClient httpclient = new DefaultHttpClient();
31
41
                // Prepare a request object
150
160
                    file.setExecutable(true);
151
161
                }
152
162
    }
 
163
    
 
164
    public static int calculateDownloadSize(List<JsonChannelParser.File> files) {
 
165
        int size = 0;
 
166
        for(JsonChannelParser.File f : files) {
 
167
                size += f.size;
 
168
                if (!f.signature.equals("")){
 
169
                        size += SIGNATURE_SIZE;
 
170
                }
 
171
        }
 
172
        return size;
 
173
    }
153
174
}