summaryrefslogtreecommitdiff
path: root/src/de/danoeh/antennapod/activity/OpmlImportActivity.java
blob: a84450e815b407eb8026f0d039263928a23a4b68 (plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package de.danoeh.antennapod.activity;

import java.io.File;

import android.os.Bundle;
import android.util.Log;
import android.widget.Button;
import android.widget.TextView;

import com.actionbarsherlock.app.SherlockActivity;

import de.danoeh.antennapod.AppConfig;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.util.StorageUtils;

public class OpmlImportActivity extends SherlockActivity {
	private static final String TAG = "OpmlImportActivity";
	
	private static final String IMPORT_DIR = "import/";
	
	private TextView txtvPath;
	private Button butStart;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		getSupportActionBar().setDisplayHomeAsUpEnabled(true);
		setContentView(R.layout.opml_import);
		
		txtvPath = (TextView) findViewById(R.id.txtvPath);
		butStart = (Button) findViewById(R.id.butStartImport);
	}

	@Override
	protected void onResume() {
		super.onResume();
		StorageUtils.checkStorageAvailability(this);
		setImportPath();
	}
	
	private void setImportPath() {
		File importDir = getExternalFilesDir(IMPORT_DIR);
		boolean success = true;
		if (!importDir.exists()) {
			if (AppConfig.DEBUG) Log.d(TAG, "Import directory doesn't exist. Creating...");
			success = importDir.mkdir();
			if (!success) {
				Log.e(TAG, "Could not create directory");
			}	
		}
		if (success) {
			txtvPath.setText(importDir.toString());
		} else {
			txtvPath.setText(R.string.opml_directory_error);
		}
	}
}