| 1 |
58fd2ec0
|
leszek
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2 |
|
|
// Copyright 2020 Leszek Koltunski //
|
| 3 |
|
|
// //
|
| 4 |
|
|
// This file is part of Magic Cube. //
|
| 5 |
|
|
// //
|
| 6 |
|
|
// Magic Cube is proprietary software licensed under an EULA which you should have received //
|
| 7 |
|
|
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html //
|
| 8 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 9 |
|
|
|
| 10 |
|
|
package org.distorted.config;
|
| 11 |
|
|
|
| 12 |
|
|
import android.view.View;
|
| 13 |
|
|
import android.widget.LinearLayout;
|
| 14 |
|
|
|
| 15 |
|
|
import org.distorted.helpers.TransparentImageButton;
|
| 16 |
|
|
import org.distorted.main.R;
|
| 17 |
|
|
|
| 18 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 19 |
|
|
|
| 20 |
|
|
public class ConfigScreen
|
| 21 |
|
|
{
|
| 22 |
|
|
private TransparentImageButton mBackButton, mResetButton;
|
| 23 |
|
|
|
| 24 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 25 |
|
|
|
| 26 |
|
|
private void setupBackButton(final ConfigActivity act)
|
| 27 |
|
|
{
|
| 28 |
|
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
|
| 29 |
|
|
mBackButton = new TransparentImageButton(act,R.drawable.ui_smallback,params);
|
| 30 |
|
|
|
| 31 |
|
|
mBackButton.setOnClickListener( new View.OnClickListener()
|
| 32 |
|
|
{
|
| 33 |
|
|
@Override
|
| 34 |
|
|
public void onClick(View v)
|
| 35 |
|
|
{
|
| 36 |
|
|
act.finish();
|
| 37 |
|
|
}
|
| 38 |
|
|
});
|
| 39 |
|
|
}
|
| 40 |
|
|
|
| 41 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 42 |
|
|
|
| 43 |
|
|
private void setupResetButton(final ConfigActivity act)
|
| 44 |
|
|
{
|
| 45 |
|
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
|
| 46 |
|
|
mResetButton = new TransparentImageButton(act,R.drawable.ui_reset,params);
|
| 47 |
|
|
|
| 48 |
|
|
mResetButton.setOnClickListener( new View.OnClickListener()
|
| 49 |
|
|
{
|
| 50 |
|
|
@Override
|
| 51 |
|
|
public void onClick(View v)
|
| 52 |
|
|
{
|
| 53 |
|
|
ConfigRenderer renderer = act.getRenderer();
|
| 54 |
|
|
renderer.setupReset();
|
| 55 |
|
|
}
|
| 56 |
|
|
});
|
| 57 |
|
|
}
|
| 58 |
|
|
|
| 59 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 60 |
|
|
|
| 61 |
|
|
void onAttachedToWindow(final ConfigActivity act, final int objectOrdinal)
|
| 62 |
|
|
{
|
| 63 |
|
|
int width = act.getScreenWidthInPixels();
|
| 64 |
|
|
|
| 65 |
|
|
LinearLayout.LayoutParams paramsL = new LinearLayout.LayoutParams(width/4, LinearLayout.LayoutParams.MATCH_PARENT);
|
| 66 |
|
|
LinearLayout.LayoutParams paramsM = new LinearLayout.LayoutParams(width/2, LinearLayout.LayoutParams.MATCH_PARENT);
|
| 67 |
|
|
LinearLayout.LayoutParams paramsR = new LinearLayout.LayoutParams(width/4, LinearLayout.LayoutParams.MATCH_PARENT);
|
| 68 |
|
|
|
| 69 |
|
|
LinearLayout layoutLeft = new LinearLayout(act);
|
| 70 |
|
|
layoutLeft.setLayoutParams(paramsL);
|
| 71 |
|
|
LinearLayout layoutMid = new LinearLayout(act);
|
| 72 |
|
|
layoutMid.setLayoutParams(paramsM);
|
| 73 |
|
|
LinearLayout layoutRight= new LinearLayout(act);
|
| 74 |
|
|
layoutRight.setLayoutParams(paramsR);
|
| 75 |
|
|
|
| 76 |
|
|
setupBackButton(act);
|
| 77 |
|
|
setupResetButton(act);
|
| 78 |
|
|
layoutLeft.addView(mResetButton);
|
| 79 |
|
|
layoutRight.addView(mBackButton);
|
| 80 |
|
|
|
| 81 |
|
|
LinearLayout layout = act.findViewById(R.id.lowerBar);
|
| 82 |
|
|
layout.removeAllViews();
|
| 83 |
|
|
layout.addView(layoutLeft);
|
| 84 |
|
|
layout.addView(layoutMid);
|
| 85 |
|
|
layout.addView(layoutRight);
|
| 86 |
|
|
}
|
| 87 |
|
|
}
|