Revision 2ceeb6b5
Added by Leszek Koltunski almost 2 years ago
src/main/java/org/distorted/bandaged/BandagedCreatorActivity.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package org.distorted.bandaged; |
11 | 11 |
|
12 |
import static android.view.View.LAYOUT_DIRECTION_RTL; |
|
13 |
|
|
12 | 14 |
import java.io.InputStream; |
13 | 15 |
|
14 | 16 |
import android.content.Intent; |
15 | 17 |
import android.content.SharedPreferences; |
18 |
import android.content.res.Configuration; |
|
16 | 19 |
import android.graphics.Bitmap; |
17 | 20 |
import android.os.Build; |
18 | 21 |
import android.os.Bundle; |
... | ... | |
42 | 45 |
private static final float RATIO_BUT = 0.07f; |
43 | 46 |
static final float RATIO_SCROLL= 0.30f; |
44 | 47 |
|
45 |
public static final float DIALOG_BUTTON_SIZE = 0.06f; |
|
46 | 48 |
public static final float SPINNER_TEXT_SIZE = 0.03f; |
47 | 49 |
|
48 | 50 |
public static final int FLAGS = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
... | ... | |
54 | 56 |
private static int mScreenWidth, mScreenHeight; |
55 | 57 |
private int mCurrentApiVersion; |
56 | 58 |
private BandagedCreatorScreen mScreen; |
59 |
private boolean mRTL; |
|
57 | 60 |
|
58 | 61 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
59 | 62 |
|
... | ... | |
70 | 73 |
mScreenWidth =displaymetrics.widthPixels; |
71 | 74 |
mScreenHeight=displaymetrics.heightPixels; |
72 | 75 |
|
76 |
final Configuration config = getResources().getConfiguration(); |
|
77 |
final int layoutDirection = config.getLayoutDirection(); |
|
78 |
mRTL = layoutDirection==LAYOUT_DIRECTION_RTL; |
|
79 |
|
|
73 | 80 |
hideNavigationBar(); |
74 | 81 |
cutoutHack(); |
75 | 82 |
computeHeights(); |
... | ... | |
233 | 240 |
renderer.changeObject(x,y,z); |
234 | 241 |
} |
235 | 242 |
|
243 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
244 |
|
|
245 |
public boolean isRTL() |
|
246 |
{ |
|
247 |
return mRTL; |
|
248 |
} |
|
249 |
|
|
236 | 250 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
237 | 251 |
|
238 | 252 |
public BandagedCreatorRenderer getRenderer() |
src/main/java/org/distorted/bandaged/BandagedCreatorObjectView.java | ||
---|---|---|
42 | 42 |
int height = act.getScreenHeightInPixels(); |
43 | 43 |
int textSize = (int)(height*TEXT_SIZE); |
44 | 44 |
|
45 |
LinearLayout.LayoutParams params = createPaneParams(height,leftmost); |
|
45 |
LinearLayout.LayoutParams params = createPaneParams(height,leftmost,act.isRTL());
|
|
46 | 46 |
mPane.setLayoutParams(params); |
47 | 47 |
|
48 | 48 |
LinearLayout bottom = mPane.findViewById(R.id.bandagedCreatorObjectLayout); |
... | ... | |
85 | 85 |
|
86 | 86 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
87 | 87 |
|
88 |
static LinearLayout.LayoutParams createPaneParams(int height, boolean leftmost) |
|
88 |
static LinearLayout.LayoutParams createPaneParams(int height, boolean leftmost, boolean rtl)
|
|
89 | 89 |
{ |
90 | 90 |
int margin = (int)(height*MARGIN); |
91 | 91 |
int length = (int)(height*BandagedCreatorActivity.RATIO_SCROLL*0.65f); |
... | ... | |
93 | 93 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( length, LinearLayout.LayoutParams.MATCH_PARENT); |
94 | 94 |
params.bottomMargin = margin; |
95 | 95 |
params.topMargin = margin; |
96 |
params.leftMargin = leftmost ? margin : 0; |
|
97 |
params.rightMargin = margin; |
|
96 |
|
|
97 |
if( !rtl ) |
|
98 |
{ |
|
99 |
params.leftMargin = leftmost ? margin : 0; |
|
100 |
params.rightMargin = margin; |
|
101 |
} |
|
102 |
else |
|
103 |
{ |
|
104 |
params.rightMargin = leftmost ? margin : 0; |
|
105 |
params.leftMargin = margin; |
|
106 |
} |
|
98 | 107 |
|
99 | 108 |
return params; |
100 | 109 |
} |
src/main/java/org/distorted/bandaged/BandagedCreatorScreen.java | ||
---|---|---|
261 | 261 |
BandagedCreatorObjectView v2 = mViews.get(v); |
262 | 262 |
LinearLayout p2 = v2.getPane(); |
263 | 263 |
int height = act.getScreenHeightInPixels(); |
264 |
LinearLayout.LayoutParams params = BandagedCreatorObjectView.createPaneParams(height,true); |
|
264 |
LinearLayout.LayoutParams params = BandagedCreatorObjectView.createPaneParams(height,true,act.isRTL());
|
|
265 | 265 |
p2.setLayoutParams(params); |
266 | 266 |
} |
267 | 267 |
|
Also available in: Unified diff
Support RTL in Bandaged Creator Activity.