Skip to content

Commit 083d19b

Browse files
sapiersapier
sapier
authored and
sapier
committedJan 6, 2015
Fixes for android
Copy only minetest_game to apk by default Don't copy .git and .svn folders to apk Fix bouncing asset copy scrollbar due to long filepaths Reenable font scaling to fix broken menu on high dpi screens Implement minetest loglevel to android loglevel mapping Disable touch digging while moving around
1 parent ef0a4e3 commit 083d19b

File tree

5 files changed

+80
-21
lines changed

5 files changed

+80
-21
lines changed
 

‎build/android/Makefile

+12-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ PATHCFGFILE = path.cfg
2020

2121
ROOT = $(shell pwd)
2222

23+
GAMES_TO_COPY = minetest_game
24+
2325
################################################################################
2426
# Android Version code
2527
# Increase for each build!
@@ -631,15 +633,23 @@ assets : $(ASSETS_TIMESTAMP)
631633
cp -r ${ROOT}/../../client ${ROOT}/assets/Minetest; \
632634
cp -r ${ROOT}/../../doc ${ROOT}/assets/Minetest; \
633635
cp -r ${ROOT}/../../fonts ${ROOT}/assets/Minetest; \
634-
cp -r ${ROOT}/../../games ${ROOT}/assets/Minetest; \
636+
mkdir ${ROOT}/assets/Minetest/games; \
637+
for game in ${GAMES_TO_COPY}; \
638+
do \
639+
cp -r ${ROOT}/../../games/$$game ${ROOT}/assets/Minetest/games/; \
640+
done; \
635641
cp -r ${ROOT}/../../mods ${ROOT}/assets/Minetest; \
636642
cp -r ${ROOT}/../../po ${ROOT}/assets/Minetest; \
637643
cp -r ${ROOT}/../../textures ${ROOT}/assets/Minetest; \
638644
mkdir -p ${ROOT}/assets/Minetest/media; \
639645
cp -r ${IRRLICHT_DIR}/media/Shaders ${ROOT}/assets/Minetest/media; \
640-
cd ${ROOT}/assets; \
646+
cd ${ROOT}/assets || exit 1; \
641647
find . -name "timestamp" -exec rm {} \; ; \
642648
find . -name "*.blend" -exec rm {} \; ; \
649+
find . -name "*~" -exec rm {} \; ; \
650+
find . -type d -path "*.git" -exec rm -rf {} \; ; \
651+
find . -type d -path "*.svn" -exec rm -rf {} \; ; \
652+
find . -type f -path "*.gitignore" -exec rm -rf {} \; ; \
643653
ls -R | grep ":$$" | sed -e 's/:$$//' -e 's/\.//' -e 's/^\///' > "index.txt"; \
644654
find Minetest >"filelist.txt"; \
645655
cp ${ROOT}/${ASSETS_TIMESTAMP} ${ROOT}/${ASSETS_TIMESTAMP}.old; \

‎build/android/src/org/minetest/minetest/MinetestAssetCopy.java

+54-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.io.OutputStream;
1010
import java.util.Vector;
1111
import java.util.Iterator;
12+
import java.lang.Object;
1213

1314
import android.app.Activity;
1415
import android.content.res.AssetFileDescriptor;
@@ -20,6 +21,9 @@
2021
import android.view.Display;
2122
import android.widget.ProgressBar;
2223
import android.widget.TextView;
24+
import android.graphics.Rect;
25+
import android.graphics.Paint;
26+
import android.text.TextPaint;
2327

2428
public class MinetestAssetCopy extends Activity
2529
{
@@ -244,14 +248,62 @@ else if (len < 0)
244248
*/
245249
protected void onProgressUpdate(Integer... progress)
246250
{
251+
247252
if (m_copy_started)
248253
{
254+
boolean shortened = false;
255+
String todisplay = m_tocopy.get(progress[0]);
249256
m_ProgressBar.setProgress(progress[0]);
250-
m_Filename.setText(m_tocopy.get(progress[0]));
257+
258+
// make sure our text doesn't exceed our layout width
259+
Rect bounds = new Rect();
260+
Paint textPaint = m_Filename.getPaint();
261+
textPaint.getTextBounds(todisplay, 0, todisplay.length(), bounds);
262+
263+
while (bounds.width() > getResources().getDisplayMetrics().widthPixels * 0.7) {
264+
Log.e("MinetestAssetCopy", todisplay + ": " +
265+
bounds.width() + " > " + (getResources().getDisplayMetrics().widthPixels * 0.7));
266+
if (todisplay.length() < 2) {
267+
break;
268+
}
269+
todisplay = todisplay.substring(1);
270+
textPaint.getTextBounds(todisplay, 0, todisplay.length(), bounds);
271+
shortened = true;
272+
}
273+
274+
if (! shortened) {
275+
m_Filename.setText(todisplay);
276+
}
277+
else {
278+
m_Filename.setText(".." + todisplay);
279+
}
251280
}
252281
else
253282
{
254-
m_Filename.setText("scanning " + m_Foldername + " ...");
283+
boolean shortened = false;
284+
String todisplay = m_Foldername;
285+
String full_text = "scanning " + todisplay + " ...";
286+
// make sure our text doesn't exceed our layout width
287+
Rect bounds = new Rect();
288+
Paint textPaint = m_Filename.getPaint();
289+
textPaint.getTextBounds(full_text, 0, full_text.length(), bounds);
290+
291+
while (bounds.width() > getResources().getDisplayMetrics().widthPixels * 0.7) {
292+
if (todisplay.length() < 2) {
293+
break;
294+
}
295+
todisplay = todisplay.substring(1);
296+
full_text = "scanning " + todisplay + " ...";
297+
textPaint.getTextBounds(full_text, 0, full_text.length(), bounds);
298+
shortened = true;
299+
}
300+
301+
if (! shortened) {
302+
m_Filename.setText(full_text);
303+
}
304+
else {
305+
m_Filename.setText("scanning .." + todisplay + " ...");
306+
}
255307
}
256308
}
257309

‎src/guiFormSpecMenu.cpp

-16
Original file line numberDiff line numberDiff line change
@@ -76,21 +76,6 @@ static unsigned int font_line_height(gui::IGUIFont *font)
7676

7777
static gui::IGUIFont *select_font_by_line_height(double target_line_height)
7878
{
79-
return g_fontengine->getFont();
80-
81-
/* I have no idea what this is trying to achieve, but scaling the font according
82-
* to the size of a formspec/dialog does not seem to be a standard (G)UI
83-
* design and AFAIK no existing nor proposed GUI does this. Besides that it:
84-
* a) breaks most (current) formspec layouts
85-
* b) font sizes change depending on the size of the formspec/dialog (see above)
86-
* meaning that there is no UI consistency
87-
* c) the chosen fonts are, in general, probably too large
88-
*
89-
* Disabling for now.
90-
*
91-
* FIXME
92-
*/
93-
#if 0
9479
// We don't get to directly select a font according to its
9580
// baseline-to-baseline height. Rather, we select by em size.
9681
// The ratio between these varies between fonts. The font
@@ -120,7 +105,6 @@ static gui::IGUIFont *select_font_by_line_height(double target_line_height)
120105
}
121106
}
122107
return g_fontengine->getFont(target_line_height - lohgt < hihgt - target_line_height ? loreq : hireq);
123-
#endif
124108
}
125109

126110
GUIFormSpecMenu::GUIFormSpecMenu(irr::IrrlichtDevice* dev,

‎src/log.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2929
#include "porting.h"
3030
#include "config.h"
3131

32+
#ifdef __ANDROID__
33+
unsigned int android_log_level_mapping[] {
34+
/* LMT_ERROR */ ANDROID_LOG_ERROR,
35+
/* LMT_ACTION */ ANDROID_LOG_WARN,
36+
/* LMT_INFO */ ANDROID_LOG_INFO,
37+
/* LMT_VERBOSE */ ANDROID_LOG_VERBOSE
38+
};
39+
#endif
40+
3241
std::list<ILogOutput*> log_outputs[LMT_NUM_VALUES];
3342
std::map<threadid_t, std::string> log_threadnames;
3443
JMutex log_threadnamemutex;
@@ -160,7 +169,7 @@ class Logbuf : public std::streambuf
160169
{
161170
log_printline(m_lev, m_buf);
162171
#ifdef __ANDROID__
163-
__android_log_print(ANDROID_LOG_ERROR, PROJECT_NAME, "%s", m_buf.c_str());
172+
__android_log_print(android_log_level_mapping[m_lev], PROJECT_NAME, "%s", m_buf.c_str());
164173
#endif
165174
}
166175

‎src/touchscreengui.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,10 @@ void TouchScreenGUI::step(float dtime)
683683
if (btn->ids.size() > 0) {
684684
btn->repeatcounter += dtime;
685685

686+
/* in case we're moving around digging does not happen */
687+
if (m_move_id != -1)
688+
m_move_has_really_moved = true;
689+
686690
if (btn->repeatcounter < 0.2) continue;
687691

688692
btn->repeatcounter = 0;

0 commit comments

Comments
 (0)
Please sign in to comment.