-
-
Notifications
You must be signed in to change notification settings - Fork 208
Expand file tree
/
Copy pathTedFontActivity.java
More file actions
97 lines (76 loc) · 2.48 KB
/
Copy pathTedFontActivity.java
File metadata and controls
97 lines (76 loc) · 2.48 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package org.qpython.qpy.texteditor;
import java.io.File;
import java.util.LinkedList;
import org.qpython.qpy.R;
import org.qpython.qpy.texteditor.ui.adapter.FontListAdapter;
import org.qpython.qpy.texteditor.widget.crouton.Crouton;
import org.qpython.qpy.texteditor.widget.crouton.Style;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import org.qpython.qpy.texteditor.androidlib.ui.activity.BrowsingActivity;
public class TedFontActivity extends BrowsingActivity implements
OnClickListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_open);
mExtensionsWhiteList.add("ttf");
// set default result
setResult(RESULT_CANCELED, null);
// buttons
findViewById(R.id.buttonCancel).setOnClickListener(this);
mListAdapter = new FontListAdapter(this, new LinkedList<>());
}
@Override
protected void onFileClick(File file) {
if (setOpenResult(file))
finish();
}
@Override
protected boolean onFolderClick(File folder) {
return true;
}
@Override
protected void onFolderViewFilled() {
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
// navigate to parent folder
if (!mCurrentFolder.getPath().equals("/storage/emulated/0")) {
File parent = mCurrentFolder.getParentFile();
if ((parent != null) && (parent.exists())) {
fillFolderView(parent);
return true;
}
}
}
return super.onKeyUp(keyCode, event);
}
@Override
public void onClick(View v) {
if (v.getId() == R.id.buttonCancel) {
setResult(RESULT_CANCELED);
finish();
}
}
/**
* @param file the file to return
* @return if the result was set correctly
*/
protected boolean setOpenResult(File file) {
Intent result;
if (!file.canRead()) {
Crouton.showText(this, R.string.toast_file_cant_read, Style.ALERT);
return false;
}
result = new Intent();
result.setData(Uri.fromFile(file));
setResult(RESULT_OK, result);
return true;
}
}