| 10 |
10 |
package org.distorted.main;
|
| 11 |
11 |
|
| 12 |
12 |
import android.content.Context;
|
| 13 |
|
import android.content.res.Resources;
|
| 14 |
|
import android.graphics.drawable.ColorDrawable;
|
| 15 |
13 |
import android.util.TypedValue;
|
| 16 |
14 |
import android.view.Gravity;
|
| 17 |
15 |
import android.view.LayoutInflater;
|
| ... | ... | |
| 26 |
24 |
import org.json.JSONException;
|
| 27 |
25 |
import org.json.JSONObject;
|
| 28 |
26 |
|
|
27 |
import java.text.SimpleDateFormat;
|
|
28 |
import java.util.Date;
|
|
29 |
import java.util.Locale;
|
|
30 |
|
| 29 |
31 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 30 |
32 |
|
| 31 |
33 |
public class MainSolvesPopup
|
| ... | ... | |
| 48 |
50 |
mPadding = (int)(mHeight*0.01f);
|
| 49 |
51 |
|
| 50 |
52 |
LayoutInflater layoutInflater = (LayoutInflater)act.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
| 51 |
|
final View layout = layoutInflater.inflate(R.layout.dialog_scrollable_panes, null);
|
|
53 |
final View layout = layoutInflater.inflate(R.layout.dialog_scrollable_solves, null);
|
| 52 |
54 |
mPopup = new PopupWindow(act);
|
| 53 |
55 |
mPopup.setContentView(layout);
|
| 54 |
56 |
mPopup.setFocusable(true);
|
| 55 |
|
|
| 56 |
|
Resources res = act.getResources();
|
| 57 |
|
int l = res.getColor(act.getLightTrans());
|
| 58 |
|
mPopup.setBackgroundDrawable(new ColorDrawable(l));
|
| 59 |
|
|
| 60 |
57 |
mLayout= layout.findViewById(R.id.dialog_scrollable_main_layout);
|
| 61 |
58 |
|
| 62 |
59 |
fillLayout(act,array);
|
| ... | ... | |
| 74 |
71 |
LinearLayout.LayoutParams pL = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, mSize );
|
| 75 |
72 |
pL.setMargins(mMargin, mMargin, mMargin, mMargin);
|
| 76 |
73 |
LinearLayout.LayoutParams pT = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, textH );
|
| 77 |
|
LinearLayout.LayoutParams pB = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, buttH );
|
| 78 |
74 |
|
| 79 |
75 |
int numSolves = array.length();
|
| 80 |
76 |
|
| ... | ... | |
| 84 |
80 |
{
|
| 85 |
81 |
JSONObject object = array.getJSONObject(s);
|
| 86 |
82 |
long time = object.getLong("time");
|
| 87 |
|
View pane = createOldPane(act, time, pL, pT, pB);
|
|
83 |
View pane = createOldPane(act, time, pL, pT);
|
| 88 |
84 |
mLayout.addView(pane);
|
| 89 |
85 |
}
|
| 90 |
86 |
}
|
| ... | ... | |
| 93 |
89 |
android.util.Log.e("D", "fillLayout: JSON error: "+jex.getMessage());
|
| 94 |
90 |
}
|
| 95 |
91 |
|
| 96 |
|
View pane = createNewPane(act, pL,pT,pB);
|
|
92 |
View pane = createNewPane(act, pL, pT);
|
| 97 |
93 |
mLayout.addView(pane);
|
| 98 |
94 |
}
|
| 99 |
95 |
|
| 100 |
96 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 101 |
97 |
|
| 102 |
|
private View createOldPane(MainActivity act, long time, LinearLayout.LayoutParams pView, LinearLayout.LayoutParams pText, LinearLayout.LayoutParams pButt)
|
|
98 |
private String convertToDate(Date date)
|
|
99 |
{
|
|
100 |
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MMM-dd", Locale.getDefault());
|
|
101 |
return sdf.format(date);
|
|
102 |
}
|
|
103 |
|
|
104 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
105 |
|
|
106 |
private String convertToTime(Date date)
|
|
107 |
{
|
|
108 |
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss", Locale.getDefault());
|
|
109 |
return sdf.format(date);
|
|
110 |
}
|
|
111 |
|
|
112 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
113 |
|
|
114 |
private View createOldPane(MainActivity act, long time, LinearLayout.LayoutParams pView, LinearLayout.LayoutParams pText)
|
| 103 |
115 |
{
|
| 104 |
116 |
View view = act.getLayoutInflater().inflate(R.layout.dialog_solve_old_pane, null);
|
| 105 |
117 |
TextView title = view.findViewById(R.id.solves_pane_title);
|
|
118 |
TextView dt = view.findViewById(R.id.solves_pane_date);
|
| 106 |
119 |
TextView tm = view.findViewById(R.id.solves_pane_time);
|
| 107 |
|
tm.setText(Long.toString(time));
|
|
120 |
|
|
121 |
Date date = new Date(time);
|
|
122 |
dt.setText(convertToDate(date));
|
|
123 |
tm.setText(convertToTime(date));
|
| 108 |
124 |
|
| 109 |
125 |
view.setLayoutParams(pView);
|
| 110 |
126 |
view.setPadding(mPadding,mPadding,mPadding,mPadding);
|
| 111 |
127 |
|
| 112 |
128 |
title.setTextSize(TypedValue.COMPLEX_UNIT_PX, mFontSize);
|
|
129 |
dt.setTextSize(TypedValue.COMPLEX_UNIT_PX, mFontSize);
|
| 113 |
130 |
tm.setTextSize(TypedValue.COMPLEX_UNIT_PX, mFontSize);
|
| 114 |
131 |
title.setLayoutParams(pText);
|
|
132 |
dt.setLayoutParams(pText);
|
| 115 |
133 |
tm.setLayoutParams(pText);
|
| 116 |
134 |
|
| 117 |
135 |
Button but1 = view.findViewById(R.id.solves_pane_delete);
|
|
136 |
but1.setTextSize(TypedValue.COMPLEX_UNIT_PX, mFontSize);
|
| 118 |
137 |
|
| 119 |
138 |
but1.setOnClickListener( new View.OnClickListener()
|
| 120 |
139 |
{
|
| ... | ... | |
| 125 |
144 |
}
|
| 126 |
145 |
});
|
| 127 |
146 |
|
| 128 |
|
but1.setTextSize(TypedValue.COMPLEX_UNIT_PX, mFontSize);
|
| 129 |
|
but1.setLayoutParams(pButt);
|
| 130 |
|
|
| 131 |
147 |
Button but2 = view.findViewById(R.id.solves_pane_resume);
|
|
148 |
but2.setTextSize(TypedValue.COMPLEX_UNIT_PX, mFontSize);
|
| 132 |
149 |
|
| 133 |
150 |
but2.setOnClickListener( new View.OnClickListener()
|
| 134 |
151 |
{
|
| ... | ... | |
| 139 |
156 |
}
|
| 140 |
157 |
});
|
| 141 |
158 |
|
| 142 |
|
but2.setTextSize(TypedValue.COMPLEX_UNIT_PX, mFontSize);
|
| 143 |
|
but2.setLayoutParams(pButt);
|
| 144 |
|
|
| 145 |
159 |
return view;
|
| 146 |
160 |
}
|
| 147 |
161 |
|
| 148 |
162 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 149 |
163 |
|
| 150 |
|
private View createNewPane(MainActivity act, LinearLayout.LayoutParams pView, LinearLayout.LayoutParams pText, LinearLayout.LayoutParams pButt)
|
|
164 |
private View createNewPane(MainActivity act, LinearLayout.LayoutParams pView, LinearLayout.LayoutParams pText)
|
| 151 |
165 |
{
|
| 152 |
166 |
View view = act.getLayoutInflater().inflate(R.layout.dialog_solve_new_pane, null);
|
| 153 |
167 |
TextView title = view.findViewById(R.id.solves_pane_title);
|
| ... | ... | |
| 159 |
173 |
title.setLayoutParams(pText);
|
| 160 |
174 |
|
| 161 |
175 |
Button but = view.findViewById(R.id.solves_pane_play);
|
|
176 |
but.setTextSize(TypedValue.COMPLEX_UNIT_PX, mFontSize);
|
| 162 |
177 |
|
| 163 |
178 |
but.setOnClickListener( new View.OnClickListener()
|
| 164 |
179 |
{
|
| ... | ... | |
| 169 |
184 |
}
|
| 170 |
185 |
});
|
| 171 |
186 |
|
| 172 |
|
but.setTextSize(TypedValue.COMPLEX_UNIT_PX, mFontSize);
|
| 173 |
|
but.setLayoutParams(pButt);
|
| 174 |
|
|
| 175 |
187 |
return view;
|
| 176 |
188 |
}
|
| 177 |
189 |
|
Progress remembering solves.