Project

General

Profile

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

magiccube / src / main / java / org / distorted / dialogs / RubikDialogUpdateView.java @ 9fde123a

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2022 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
package org.distorted.dialogs;
21

    
22
import android.app.Activity;
23
import android.util.TypedValue;
24
import android.view.View;
25
import android.widget.Button;
26
import android.widget.ImageView;
27
import android.widget.LinearLayout;
28
import android.widget.ProgressBar;
29
import android.widget.TextView;
30

    
31
import org.distorted.main.R;
32
import org.distorted.network.RubikUpdates;
33

    
34
import static android.view.View.GONE;
35

    
36
///////////////////////////////////////////////////////////////////////////////////////////////////
37

    
38
public class RubikDialogUpdateView
39
  {
40
  public RubikDialogUpdateView()
41
    {
42

    
43
    }
44

    
45
///////////////////////////////////////////////////////////////////////////////////////////////////
46

    
47
  public View createView(Activity act, RubikUpdates.UpdateInfo info, int fontSize, int padding,
48
                         LinearLayout.LayoutParams pImage, LinearLayout.LayoutParams pView,
49
                         LinearLayout.LayoutParams pText, LinearLayout.LayoutParams pButt )
50
    {
51
    View view = act.getLayoutInflater().inflate(R.layout.dialog_updates_pane, null);
52
    TextView title = view.findViewById(R.id.updates_pane_title);
53
    title.setText(info.mObjectLongName);
54
    TextView description = view.findViewById(R.id.updates_pane_description);
55
    description.setText(info.mDescription);
56

    
57
    ImageView image = view.findViewById(R.id.updates_pane_image);
58
    image.setBackgroundResource(R.drawable.unknown_icon);
59

    
60
    image.setLayoutParams(pImage);
61
    view.setLayoutParams(pView);
62

    
63
    title.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize);
64
    description.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize);
65

    
66
    title.setLayoutParams(pText);
67
    description.setLayoutParams(pText);
68

    
69
    view.setPadding(padding,padding,padding,padding);
70

    
71
    ProgressBar bar = view.findViewById(R.id.updates_pane_bar);
72
    Button button   = view.findViewById(R.id.updates_pane_button);
73

    
74
    if( info.mPercent>=100 )
75
      {
76
      bar.setVisibility(GONE);
77
      button.setOnClickListener( new View.OnClickListener()
78
        {
79
        @Override
80
        public void onClick(View v)
81
          {
82
          android.util.Log.e("D", "INSTALL pressed");
83
          }
84
        });
85

    
86
      button.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize);
87
      button.setLayoutParams(pButt);
88
      }
89
    else
90
      {
91
      button.setVisibility(GONE);
92
      bar.setLayoutParams(pButt);
93
      bar.setProgress(info.mPercent);
94
      }
95

    
96
    return view;
97
    }
98
  }
(20-20/21)