This source file includes following definitions.
- startEmacsQ
- startEmacsDebugInit
- eraseDumpFile
- onCreate
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.gnu.emacs;
21
22 import java.io.File;
23
24 import android.app.Activity;
25
26 import android.content.Intent;
27
28 import android.os.Bundle;
29 import android.os.Build;
30
31 import android.widget.Toast;
32
33 import android.preference.*;
34
35
36
37
38
39
40
41
42
43
44 @SuppressWarnings ("deprecation")
45 public class EmacsPreferencesActivity extends PreferenceActivity
46 {
47
48
49
50
51 private void
52 startEmacsQ ()
53 {
54 Intent intent;
55
56 intent = new Intent (this, EmacsActivity.class);
57 intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK
58 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
59 intent.putExtra ("org.gnu.emacs.STARTUP_ARGUMENT", "--quick");
60 startActivity (intent);
61 System.exit (0);
62 }
63
64
65
66
67
68 private void
69 startEmacsDebugInit ()
70 {
71 Intent intent;
72
73 intent = new Intent (this, EmacsActivity.class);
74 intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK
75 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
76 intent.putExtra ("org.gnu.emacs.STARTUP_ARGUMENT", "--debug-init");
77 startActivity (intent);
78 System.exit (0);
79 }
80
81
82
83 private void
84 eraseDumpFile ()
85 {
86 String wantedDumpFile;
87 File file;
88 Toast toast;
89
90 wantedDumpFile = ("emacs-" + EmacsNative.getFingerprint ()
91 + ".pdmp");
92 file = new File (getFilesDir (), wantedDumpFile);
93
94 if (file.exists ())
95 file.delete ();
96
97
98
99
100 EmacsApplication.dumpFileName = null;
101
102
103
104 toast = Toast.makeText (this, "Dump file removed",
105 Toast.LENGTH_SHORT);
106 toast.show ();
107 }
108
109 @Override
110 public final void
111 onCreate (Bundle savedInstanceState)
112 {
113 Preference tem;
114 Preference.OnPreferenceClickListener listener;
115
116 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
117 setTheme (android.R.style.Theme_DeviceDefault_Settings);
118 else if (Build.VERSION.SDK_INT
119 >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
120 setTheme (android.R.style.Theme_DeviceDefault);
121
122
123 super.onCreate (savedInstanceState);
124
125
126 addPreferencesFromResource (R.xml.preferences);
127
128
129
130
131 tem = findPreference ("start_quick");
132 listener = new Preference.OnPreferenceClickListener () {
133 @Override
134 public boolean
135 onPreferenceClick (Preference preference)
136 {
137 startEmacsQ ();
138 return true;
139 }
140 };
141
142 tem.setOnPreferenceClickListener (listener);
143 tem = findPreference ("start_debug_init");
144 listener = new Preference.OnPreferenceClickListener () {
145 @Override
146 public boolean
147 onPreferenceClick (Preference preference)
148 {
149 startEmacsDebugInit ();
150 return true;
151 }
152 };
153
154 tem.setOnPreferenceClickListener (listener);
155 tem = findPreference ("erase_dump");
156 listener = new Preference.OnPreferenceClickListener () {
157 @Override
158 public boolean
159 onPreferenceClick (Preference preference)
160 {
161 eraseDumpFile ();
162 return true;
163 }
164 };
165
166 tem.setOnPreferenceClickListener (listener);
167 }
168 };