Project

General

Profile

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

magiccube / src / main / java / org / distorted / dialogs / RubikDialogUpdateView.java @ b88cdd91

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 pImage, LinearLayout.LayoutParams pView,
47
                         LinearLayout.LayoutParams pText, LinearLayout.LayoutParams pButt )
48
    {
49
    View view = act.getLayoutInflater().inflate(R.layout.dialog_updates_pane, null);
50
    TextView title = view.findViewById(R.id.updates_pane_title);
51
    title.setText(info.mObjectLongName);
52
    TextView description = view.findViewById(R.id.updates_pane_description);
53
    description.setText(info.mDescription);
54

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

    
58
    mIcon.setLayoutParams(pImage);
59
    view.setLayoutParams(pView);
60

    
61
    title.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize);
62
    description.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize);
63

    
64
    title.setLayoutParams(pText);
65
    description.setLayoutParams(pText);
66

    
67
    view.setPadding(padding,padding,padding,padding);
68

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

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

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

    
94
    return view;
95
    }
96

    
97
///////////////////////////////////////////////////////////////////////////////////////////////////
98

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