Skip to content

Commit

Permalink
Android: shorten initial progress bar text way more simple
Browse files Browse the repository at this point in the history
  • Loading branch information
Sapier authored and Sapier committed Dec 23, 2015
1 parent 98d16e0 commit 9c9b02c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 43 deletions.
4 changes: 3 additions & 1 deletion build/android/res/layout/assetcopy.xml
Expand Up @@ -13,8 +13,10 @@

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="middle"
android:singleLine="true"
android:layout_gravity="center_horizontal"
android:text="preparing media ..."
android:textAppearance="?android:attr/textAppearanceSmall" />
Expand Down
44 changes: 2 additions & 42 deletions build/android/src/net/minetest/minetest/MinetestAssetCopy.java
Expand Up @@ -254,54 +254,14 @@ protected void onProgressUpdate(Integer... progress)
boolean shortened = false;
String todisplay = m_tocopy.get(progress[0]);
m_ProgressBar.setProgress(progress[0]);

// make sure our text doesn't exceed our layout width
Rect bounds = new Rect();
Paint textPaint = m_Filename.getPaint();
textPaint.getTextBounds(todisplay, 0, todisplay.length(), bounds);

while (bounds.width() > getResources().getDisplayMetrics().widthPixels * 0.7) {
if (todisplay.length() < 2) {
break;
}
todisplay = todisplay.substring(1);
textPaint.getTextBounds(todisplay, 0, todisplay.length(), bounds);
shortened = true;
}

if (! shortened) {
m_Filename.setText(todisplay);
}
else {
m_Filename.setText(".." + todisplay);
}
m_Filename.setText(todisplay);
}
else
{
boolean shortened = false;
String todisplay = m_Foldername;
String full_text = "scanning " + todisplay + " ...";
// make sure our text doesn't exceed our layout width
Rect bounds = new Rect();
Paint textPaint = m_Filename.getPaint();
textPaint.getTextBounds(full_text, 0, full_text.length(), bounds);

while (bounds.width() > getResources().getDisplayMetrics().widthPixels * 0.7) {
if (todisplay.length() < 2) {
break;
}
todisplay = todisplay.substring(1);
full_text = "scanning " + todisplay + " ...";
textPaint.getTextBounds(full_text, 0, full_text.length(), bounds);
shortened = true;
}

if (! shortened) {
m_Filename.setText(full_text);
}
else {
m_Filename.setText("scanning .." + todisplay + " ...");
}
m_Filename.setText(full_text);
}
}

Expand Down

0 comments on commit 9c9b02c

Please sign in to comment.