Project

General

Profile

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

magiccube / src / main / java / org / distorted / dialogs / RubikDialogUpdateView.java @ 06ba394a

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.graphics.Bitmap;
24
import android.util.TypedValue;
25
import android.view.View;
26
import android.widget.Button;
27
import android.widget.ImageView;
28
import android.widget.LinearLayout;
29
import android.widget.ProgressBar;
30
import android.widget.TextView;
31

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

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

    
37
///////////////////////////////////////////////////////////////////////////////////////////////////
38

    
39
public class RubikDialogUpdateView
40
  {
41
  private ImageView mIcon;
42

    
43
///////////////////////////////////////////////////////////////////////////////////////////////////
44

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

    
54
    mIcon = view.findViewById(R.id.updates_pane_image);
55
    mIcon.setImageResource(R.drawable.unknown_icon);
56

    
57
    view.setLayoutParams(pView);
58

    
59
    title.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize);
60
    description.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize);
61

    
62
    title.setLayoutParams(pText);
63
    description.setLayoutParams(pText);
64

    
65
    view.setPadding(padding,padding,padding,padding);
66

    
67
    ProgressBar bar = view.findViewById(R.id.updates_pane_bar);
68
    Button button   = view.findViewById(R.id.updates_pane_button);
69

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

    
82
      button.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize);
83
      button.setLayoutParams(pButt);
84
      }
85
    else
86
      {
87
      button.setVisibility(GONE);
88
      bar.setLayoutParams(pButt);
89
      bar.setProgress(info.mPercent);
90
      }
91

    
92
    return view;
93
    }
94

    
95
///////////////////////////////////////////////////////////////////////////////////////////////////
96

    
97
  void setIcon(Bitmap icon)
98
    {
99
    mIcon.setImageBitmap(icon);
100
    }
101
  }
(20-20/21)