Project

General

Profile

Download (4.28 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / playui / ScreenDone.java @ 4c6cbfa2

1 15ed3429 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.playui;
11
12
import android.content.SharedPreferences;
13
import android.util.TypedValue;
14
import android.view.LayoutInflater;
15
import android.view.View;
16
import android.widget.LinearLayout;
17
import android.widget.TextView;
18
19
import androidx.fragment.app.FragmentManager;
20
21
import org.distorted.dialogs.RubikDialogNewRecord;
22
import org.distorted.dialogs.RubikDialogSolved;
23
import org.distorted.helpers.TransparentImageButton;
24
import org.distorted.main.R;
25
26
///////////////////////////////////////////////////////////////////////////////////////////////////
27
28
public class ScreenDone extends ScreenAbstract
29
  {
30
  private TransparentImageButton mBackButton;
31
32
///////////////////////////////////////////////////////////////////////////////////////////////////
33
34
  void leaveScreen(PlayActivity act)
35
    {
36
37
    }
38
39
///////////////////////////////////////////////////////////////////////////////////////////////////
40
41
  void enterScreen(final PlayActivity act)
42
    {
43
    float width = act.getScreenWidthInPixels();
44
    float titleSize = width*PlayActivity.TITLE_TEXT_SIZE;
45
    LayoutInflater inflater = act.getLayoutInflater();
46
47
    // TOP ////////////////////////////
48
    LinearLayout layoutTop = act.findViewById(R.id.upperBar);
49
    layoutTop.removeAllViews();
50
    TextView label = (TextView)inflater.inflate(R.layout.upper_text, null);
51
    label.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize);
52
    label.setText(R.string.solved);
53
    layoutTop.addView(label);
54
55
    // BOT ////////////////////////////
56
    LinearLayout layoutBot = act.findViewById(R.id.lowerBar);
57
    layoutBot.removeAllViews();
58
59
    LinearLayout.LayoutParams paramsL = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1);
60
    LinearLayout.LayoutParams paramsR = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,2);
61
62
    LinearLayout layoutLeft = new LinearLayout(act);
63
    layoutLeft.setLayoutParams(paramsL);
64
    LinearLayout layoutRight = new LinearLayout(act);
65
    layoutRight.setLayoutParams(paramsR);
66
67
    setupBackButton(act);
68
69
    layoutRight.addView(mBackButton);
70
    layoutBot.addView(layoutLeft);
71
    layoutBot.addView(layoutRight);
72
    }
73
74
///////////////////////////////////////////////////////////////////////////////////////////////////
75
76
  private void setupBackButton(final PlayActivity act)
77
    {
78
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f);
79
    mBackButton = new TransparentImageButton(act,R.drawable.ui_back,params);
80
81
    mBackButton.setOnClickListener( new View.OnClickListener()
82
      {
83
      @Override
84
      public void onClick(View v)
85
        {
86
        ScreenList.goBack(act);
87
88
        FragmentManager mana = act.getSupportFragmentManager();
89
        RubikDialogNewRecord diag1 = (RubikDialogNewRecord) mana.findFragmentByTag(RubikDialogNewRecord.getDialogTag());
90
        RubikDialogSolved    diag2 = (RubikDialogSolved   ) mana.findFragmentByTag(RubikDialogSolved.getDialogTag());
91
92
        if( diag1 !=null ) diag1.dismiss();
93
        if( diag2 !=null ) diag2.dismiss();
94
        }
95
      });
96
    }
97
98
///////////////////////////////////////////////////////////////////////////////////////////////////
99
100
  public void savePreferences(SharedPreferences.Editor editor)
101
    {
102
103
    }
104
105
///////////////////////////////////////////////////////////////////////////////////////////////////
106
107
  public void restorePreferences(SharedPreferences preferences)
108
    {
109
110
    }
111
  }