Skip to content

Commit 0248d96

Browse files
author
Chris Bellew
committed
Styled changelog.
1 parent 608c50c commit 0248d96

File tree

2 files changed

+69
-28
lines changed

2 files changed

+69
-28
lines changed

mobile/src/main/java/com/atomjack/vcfp/activities/MainActivity.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,7 @@ private void init() {
452452
fragment = playerFragment != null ? playerFragment : getMainFragment();
453453

454454
// Only show the what's new dialog if this is not the first time the app is run
455-
final WhatsNewDialog whatsNewDialog = new WhatsNewDialog(this);
456-
whatsNewDialog.show();
455+
showWhatsNewDialog(false);
457456
switchToFragment(fragment);
458457
}
459458
} else {
@@ -462,6 +461,22 @@ private void init() {
462461
}
463462
}
464463

464+
private void showWhatsNewDialog(boolean force) {
465+
WhatsNewDialog whatsNewDialog = new WhatsNewDialog(this);
466+
whatsNewDialog.setStyle(String.format("body { background-color: %s; color: #ffffff; }" +
467+
"h1 { margin-left: 0px; font-size: 12pt; }"
468+
+ "li { margin-left: 0px; font-size: 9pt; }"
469+
+ "ul { padding-left: 30px; }"
470+
+ ".summary { font-size: 9pt; color: #606060; display: block; clear: left; }"
471+
+ ".date { font-size: 9pt; color: #606060; display: block; }", String.format("#%06X", (0xFFFFFF & ContextCompat.getColor(this, R.color.settings_popup_background)))));
472+
View customView = LayoutInflater.from(this).inflate(R.layout.popup_whatsnew, null, false);
473+
whatsNewDialog.setCustomView(customView);
474+
if(force || true)
475+
whatsNewDialog.forceShow();
476+
else
477+
whatsNewDialog.show();
478+
}
479+
465480
@Override
466481
protected void onPause() {
467482
super.onPause();
@@ -1619,8 +1634,7 @@ public void installTasker(MenuItem item) {
16191634
}
16201635

16211636
public void showChangelog(MenuItem item) {
1622-
final WhatsNewDialog whatsNewDialog = new WhatsNewDialog(this);
1623-
whatsNewDialog.forceShow();
1637+
showWhatsNewDialog(true);
16241638
}
16251639

16261640
public void installUtter(MenuItem item) {

mobile/src/main/java/com/cubeactive/martin/inscription/ChangeLogDialog.java

Lines changed: 51 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
import android.content.res.XmlResourceParser;
2929
import android.text.format.DateFormat;
3030
import android.util.Log;
31+
import android.view.View;
3132
import android.webkit.WebView;
33+
import android.widget.Button;
3234

3335
import com.atomjack.vcfp.R;
3436

@@ -55,6 +57,8 @@ public class ChangeLogDialog {
5557

5658
protected DialogInterface.OnDismissListener mOnDismissListener;
5759

60+
private View customView = null;
61+
5862
public ChangeLogDialog(final Context context) {
5963
mContext = context;
6064
}
@@ -184,7 +188,7 @@ public String getHTML() {
184188
//Create HTML change log
185189
return getHTMLChangelog(R.xml.changelog, resources, 0);
186190
}
187-
191+
188192
//Call to show the change log dialog
189193
public void show() {
190194
show(0);
@@ -216,35 +220,58 @@ protected void show(final int version) {
216220
return;
217221
}
218222

219-
//Create web view and load html
220-
final WebView webView = new WebView(mContext);
221-
webView.loadDataWithBaseURL(null, htmlChangelog, "text/html", "utf-8", null);
222-
final AlertDialog.Builder builder = new AlertDialog.Builder(mContext)
223-
.setTitle(title)
224-
.setView(webView)
225-
.setPositiveButton(closeString, new Dialog.OnClickListener() {
223+
224+
final AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
225+
if(customView != null) {
226+
builder.setView(customView);
227+
final AlertDialog dialog = builder.create();
228+
// customView.findViewWithTag()
229+
WebView whatsNewWebView = (WebView)customView.findViewById(mContext.getResources().getIdentifier("whatsNewWebView", "id", mContext.getPackageName()));
230+
whatsNewWebView.loadDataWithBaseURL(null, htmlChangelog, "text/html", "utf-8", null);
231+
Button whatsNewCloseButton = (Button)customView.findViewById(mContext.getResources().getIdentifier("whatsNewCloseButton", "id", mContext.getPackageName()));
232+
if(whatsNewCloseButton != null) {
233+
whatsNewCloseButton.setOnClickListener(new View.OnClickListener() {
234+
@Override
235+
public void onClick(View v) {
236+
dialog.dismiss();
237+
}
238+
});
239+
}
240+
dialog.show();
241+
} else {
242+
//Create web view and load html
243+
final WebView webView = new WebView(mContext);
244+
webView.loadDataWithBaseURL(null, htmlChangelog, "text/html", "utf-8", null);
245+
246+
builder.setTitle(title)
247+
.setView(webView)
248+
.setPositiveButton(closeString, new Dialog.OnClickListener() {
226249
public void onClick(final DialogInterface dialogInterface, final int i) {
227-
dialogInterface.dismiss();
250+
dialogInterface.dismiss();
228251
}
229-
})
230-
.setOnCancelListener( new OnCancelListener() {
231-
232-
@Override
233-
public void onCancel(DialogInterface dialog) {
234-
dialog.dismiss();
235-
}
236-
});
237-
AlertDialog dialog = builder.create();
238-
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
252+
})
253+
.setOnCancelListener(new OnCancelListener() {
254+
255+
@Override
256+
public void onCancel(DialogInterface dialog) {
257+
dialog.dismiss();
258+
}
259+
});
260+
AlertDialog dialog = builder.create();
261+
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
239262
@Override
240263
public void onDismiss(final DialogInterface dialog) {
241-
if (mOnDismissListener != null) {
242-
mOnDismissListener.onDismiss(dialog);
243-
}
264+
if (mOnDismissListener != null) {
265+
mOnDismissListener.onDismiss(dialog);
266+
}
244267
}
245-
});
246-
dialog.show();
268+
});
269+
dialog.show();
270+
}
247271
}
248272

273+
public void setCustomView(View view) {
274+
customView = view;
275+
}
249276
}
250277

0 commit comments

Comments
 (0)