aboutsummaryrefslogtreecommitdiffstats
path: root/java/org
diff options
context:
space:
mode:
authorPo Lu2023-02-10 23:03:43 +0800
committerPo Lu2023-02-10 23:03:43 +0800
commitdc120c7ad62d5f79fe50f72431d3b9bb2d7f1558 (patch)
tree47e2993d9d3e92d23f7d328fd1d82e4c01ffcf71 /java/org
parent2489126e6856bf1b06a26127b73e4bfff857f68f (diff)
downloademacs-dc120c7ad62d5f79fe50f72431d3b9bb2d7f1558.tar.gz
emacs-dc120c7ad62d5f79fe50f72431d3b9bb2d7f1558.zip
Improve appearance of the Android preferences screen
* .gitignore: Add org/gnu/emacs/R.java. * cross/Makefile.in (top_builddir): Include verbose.mk. Rewrite rules to print nice looking statements. * doc/emacs/android.texi (Android, Android Startup) (Android Environment, Android Windowing, Android Fonts): * doc/emacs/emacs.texi (Top): Add an extra ``Android Troubleshooting'' node and move troubleshooting details there. * java/Makefile.in: Generate R.java; improve appearance by using verbose.mk. * java/org/gnu/emacs/EmacsPreferencesActivity.java: Reimplement in terms of PreferencesActivity. * java/org/gnu/emacs/EmacsView.java (handleDirtyBitmap): Avoid flicker. * java/res/xml/preferences.xml: New file. * src/verbose.mk.in (AM_V_AAPT, AM_V_SILENT): New variables.
Diffstat (limited to 'java/org')
-rw-r--r--java/org/gnu/emacs/EmacsPreferencesActivity.java123
-rw-r--r--java/org/gnu/emacs/EmacsView.java5
2 files changed, 71 insertions, 57 deletions
diff --git a/java/org/gnu/emacs/EmacsPreferencesActivity.java b/java/org/gnu/emacs/EmacsPreferencesActivity.java
index 6cef7c37516..85639fe9236 100644
--- a/java/org/gnu/emacs/EmacsPreferencesActivity.java
+++ b/java/org/gnu/emacs/EmacsPreferencesActivity.java
@@ -22,27 +22,28 @@ package org.gnu.emacs;
22import java.io.File; 22import java.io.File;
23 23
24import android.app.Activity; 24import android.app.Activity;
25
25import android.content.Intent; 26import android.content.Intent;
27
26import android.os.Bundle; 28import android.os.Bundle;
27import android.os.Build; 29import android.os.Build;
28import android.view.View;
29import android.view.ViewGroup.LayoutParams;
30import android.widget.LinearLayout;
31import android.widget.TextView;
32 30
33import android.R; 31import android.widget.Toast;
32
33import android.preference.*;
34 34
35/* This module provides a ``preferences'' display for Emacs. It is 35/* This module provides a ``preferences'' display for Emacs. It is
36 supposed to be launched from inside the Settings application to 36 supposed to be launched from inside the Settings application to
37 perform various actions, such as starting Emacs with the ``-Q'' 37 perform various actions, such as starting Emacs with the ``-Q''
38 option, which would not be possible otherwise, as there is no 38 option, which would not be possible otherwise, as there is no
39 command line on Android. */ 39 command line on Android.
40 40
41public class EmacsPreferencesActivity extends Activity 41 Android provides a preferences activity, but it is deprecated.
42{ 42 Unfortunately, there is no alternative that looks the same way. */
43 /* The linear layout associated with the activity. */
44 private LinearLayout layout;
45 43
44@SuppressWarnings ("deprecation")
45public class EmacsPreferencesActivity extends PreferenceActivity
46{
46 /* Restart Emacs with -Q. Call EmacsThread.exit to kill Emacs now, and 47 /* Restart Emacs with -Q. Call EmacsThread.exit to kill Emacs now, and
47 tell the system to EmacsActivity with some parameters later. */ 48 tell the system to EmacsActivity with some parameters later. */
48 49
@@ -59,72 +60,82 @@ public class EmacsPreferencesActivity extends Activity
59 System.exit (0); 60 System.exit (0);
60 } 61 }
61 62
63 /* Erase Emacs's dump file. */
64
65 private void
66 eraseDumpFile ()
67 {
68 String wantedDumpFile;
69 File file;
70 Toast toast;
71
72 wantedDumpFile = ("emacs-" + EmacsNative.getFingerprint ()
73 + ".pdmp");
74 file = new File (getFilesDir (), wantedDumpFile);
75
76 if (file.exists ())
77 file.delete ();
78
79 /* Make sure to clear EmacsApplication.dumpFileName, or
80 starting Emacs without restarting this program will
81 make Emacs try to load a nonexistent dump file. */
82 EmacsApplication.dumpFileName = null;
83
84 /* Display a message stating that the dump file has been
85 erased. */
86 toast = Toast.makeText (this, "Dump file removed",
87 Toast.LENGTH_SHORT);
88 toast.show ();
89 }
90
62 @Override 91 @Override
63 public void 92 public void
64 onCreate (Bundle savedInstanceState) 93 onCreate (Bundle savedInstanceState)
65 { 94 {
66 LinearLayout layout; 95 Preference tem;
67 TextView textView; 96 Preference.OnPreferenceClickListener listener;
68 LinearLayout.LayoutParams params;
69 int resid;
70 97
71 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) 98 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
72 setTheme (R.style.Theme_DeviceDefault_Settings); 99 setTheme (android.R.style.Theme_DeviceDefault_Settings);
73 else if (Build.VERSION.SDK_INT 100 else if (Build.VERSION.SDK_INT
74 >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) 101 >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
75 setTheme (R.style.Theme_DeviceDefault); 102 setTheme (android.R.style.Theme_DeviceDefault);
103
104 /* This must come before using any preference APIs. */
105 super.onCreate (savedInstanceState);
76 106
77 layout = new LinearLayout (this); 107 /* Add preferences from the XML file where they are defined. */
78 layout.setOrientation (LinearLayout.VERTICAL); 108 addPreferencesFromResource (R.xml.preferences);
79 setContentView (layout);
80 109
81 textView = new TextView (this); 110 /* Now, set up on click handlers for each of the preferences
82 textView.setPadding (8, 20, 20, 8); 111 items. */
83 112
84 params = new LinearLayout.LayoutParams (LayoutParams.MATCH_PARENT, 113 tem = findPreference ("start_quick");
85 LayoutParams.WRAP_CONTENT); 114
86 textView.setLayoutParams (params); 115 listener = new Preference.OnPreferenceClickListener () {
87 textView.setText ("(Re)start Emacs with -Q");
88 textView.setOnClickListener (new View.OnClickListener () {
89 @Override 116 @Override
90 public void 117 public boolean
91 onClick (View view) 118 onPreferenceClick (Preference preference)
92 { 119 {
93 startEmacsQ (); 120 startEmacsQ ();
121 return true;
94 } 122 }
95 }); 123 };
96 layout.addView (textView); 124
125 tem.setOnPreferenceClickListener (listener);
97 126
98 textView = new TextView (this); 127 tem = findPreference ("erase_dump");
99 textView.setPadding (8, 20, 20, 8);
100 128
101 params = new LinearLayout.LayoutParams (LayoutParams.MATCH_PARENT, 129 listener = new Preference.OnPreferenceClickListener () {
102 LayoutParams.WRAP_CONTENT);
103 textView.setLayoutParams (params);
104 textView.setText ("Erase dump file");
105 textView.setOnClickListener (new View.OnClickListener () {
106 @Override 130 @Override
107 public void 131 public boolean
108 onClick (View view) 132 onPreferenceClick (Preference preference)
109 { 133 {
110 String wantedDumpFile; 134 eraseDumpFile ();
111 File file; 135 return true;
112
113 wantedDumpFile = ("emacs-" + EmacsNative.getFingerprint ()
114 + ".pdmp");
115 file = new File (getFilesDir (), wantedDumpFile);
116
117 if (file.exists ())
118 file.delete ();
119
120 /* Make sure to clear EmacsApplication.dumpFileName, or
121 starting Emacs without restarting this program will
122 make Emacs try to load a nonexistent dump file. */
123 EmacsApplication.dumpFileName = null;
124 } 136 }
125 }); 137 };
126 layout.addView (textView);
127 138
128 super.onCreate (savedInstanceState); 139 tem.setOnPreferenceClickListener (listener);
129 } 140 }
130}; 141};
diff --git a/java/org/gnu/emacs/EmacsView.java b/java/org/gnu/emacs/EmacsView.java
index 0416301101c..4fc8104e31f 100644
--- a/java/org/gnu/emacs/EmacsView.java
+++ b/java/org/gnu/emacs/EmacsView.java
@@ -181,7 +181,10 @@ public class EmacsView extends ViewGroup
181 if (oldBitmap != null) 181 if (oldBitmap != null)
182 { 182 {
183 oldBitmap.recycle (); 183 oldBitmap.recycle ();
184 surfaceView.setBitmap (null, null); 184
185 /* Make sure to set the view's bitmap to the new bitmap, or
186 ugly flicker can result. */
187 surfaceView.setBitmap (bitmap, null);
185 } 188 }
186 189
187 /* Some Android versions still don't free the bitmap until the 190 /* Some Android versions still don't free the bitmap until the