1 |
9c39179e
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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 |
b88cdd91
|
Leszek Koltunski
|
import android.graphics.Bitmap;
|
24 |
c651024f
|
Leszek Koltunski
|
import android.util.TypedValue;
|
25 |
9c39179e
|
Leszek Koltunski
|
import android.view.View;
|
26 |
|
|
import android.widget.Button;
|
27 |
7bee6064
|
Leszek Koltunski
|
import android.widget.ImageView;
|
28 |
c651024f
|
Leszek Koltunski
|
import android.widget.LinearLayout;
|
29 |
2c9ab085
|
Leszek Koltunski
|
import android.widget.ProgressBar;
|
30 |
9c39179e
|
Leszek Koltunski
|
import android.widget.TextView;
|
31 |
|
|
|
32 |
|
|
import org.distorted.main.R;
|
33 |
|
|
import org.distorted.network.RubikUpdates;
|
34 |
|
|
|
35 |
9fde123a
|
Leszek Koltunski
|
import static android.view.View.GONE;
|
36 |
|
|
|
37 |
9c39179e
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
38 |
|
|
|
39 |
|
|
public class RubikDialogUpdateView
|
40 |
|
|
{
|
41 |
b88cdd91
|
Leszek Koltunski
|
private ImageView mIcon;
|
42 |
9c39179e
|
Leszek Koltunski
|
|
43 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
44 |
|
|
|
45 |
2c9ab085
|
Leszek Koltunski
|
public View createView(Activity act, RubikUpdates.UpdateInfo info, int fontSize, int padding,
|
46 |
06ba394a
|
Leszek Koltunski
|
LinearLayout.LayoutParams pView, LinearLayout.LayoutParams pText, LinearLayout.LayoutParams pButt )
|
47 |
9c39179e
|
Leszek Koltunski
|
{
|
48 |
9fde123a
|
Leszek Koltunski
|
View view = act.getLayoutInflater().inflate(R.layout.dialog_updates_pane, null);
|
49 |
2c9ab085
|
Leszek Koltunski
|
TextView title = view.findViewById(R.id.updates_pane_title);
|
50 |
9c39179e
|
Leszek Koltunski
|
title.setText(info.mObjectLongName);
|
51 |
2c9ab085
|
Leszek Koltunski
|
TextView description = view.findViewById(R.id.updates_pane_description);
|
52 |
9c39179e
|
Leszek Koltunski
|
description.setText(info.mDescription);
|
53 |
|
|
|
54 |
b88cdd91
|
Leszek Koltunski
|
mIcon = view.findViewById(R.id.updates_pane_image);
|
55 |
|
|
mIcon.setImageResource(R.drawable.unknown_icon);
|
56 |
7bee6064
|
Leszek Koltunski
|
|
57 |
2c9ab085
|
Leszek Koltunski
|
view.setLayoutParams(pView);
|
58 |
c651024f
|
Leszek Koltunski
|
|
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 |
2c9ab085
|
Leszek Koltunski
|
view.setPadding(padding,padding,padding,padding);
|
66 |
|
|
|
67 |
9fde123a
|
Leszek Koltunski
|
ProgressBar bar = view.findViewById(R.id.updates_pane_bar);
|
68 |
|
|
Button button = view.findViewById(R.id.updates_pane_button);
|
69 |
2c9ab085
|
Leszek Koltunski
|
|
70 |
9fde123a
|
Leszek Koltunski
|
if( info.mPercent>=100 )
|
71 |
|
|
{
|
72 |
|
|
bar.setVisibility(GONE);
|
73 |
2c9ab085
|
Leszek Koltunski
|
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 |
9fde123a
|
Leszek Koltunski
|
button.setVisibility(GONE);
|
88 |
2c9ab085
|
Leszek Koltunski
|
bar.setLayoutParams(pButt);
|
89 |
|
|
bar.setProgress(info.mPercent);
|
90 |
|
|
}
|
91 |
99b8a069
|
Leszek Koltunski
|
|
92 |
2c9ab085
|
Leszek Koltunski
|
return view;
|
93 |
9c39179e
|
Leszek Koltunski
|
}
|
94 |
b88cdd91
|
Leszek Koltunski
|
|
95 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
96 |
|
|
|
97 |
|
|
void setIcon(Bitmap icon)
|
98 |
|
|
{
|
99 |
|
|
mIcon.setImageBitmap(icon);
|
100 |
|
|
}
|
101 |
9c39179e
|
Leszek Koltunski
|
}
|