2 * ownCloud Android client application
4 * Copyright (C) 2015 ownCloud Inc.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 package com
.owncloud
.android
.ui
.dialog
;
22 import android
.app
.AlertDialog
;
23 import android
.app
.Dialog
;
24 import android
.content
.DialogInterface
;
25 import android
.os
.Bundle
;
26 import android
.webkit
.WebView
;
28 import com
.actionbarsherlock
.app
.SherlockDialogFragment
;
29 import com
.owncloud
.android
.R
;
30 import com
.owncloud
.android
.utils
.DisplayUtils
;
34 * Dialog to show the contents of res/raw/CHANGELOG.txt
36 public class ChangelogDialog
extends SherlockDialogFragment
{
38 private static final String ARG_CANCELABLE
= ChangelogDialog
.class.getCanonicalName() + ".ARG_CANCELABLE";
42 * Public factory method to get dialog instances.
44 * @param cancelable If 'true', the dialog can be cancelled by the user input (BACK button, touch outside...)
45 * @return New dialog instance, ready to show.
47 public static ChangelogDialog
newInstance(boolean cancelable
) {
48 ChangelogDialog fragment
= new ChangelogDialog();
49 Bundle args
= new Bundle();
50 args
.putBoolean(ARG_CANCELABLE
, cancelable
);
51 fragment
.setArguments(args
);
60 public Dialog
onCreateDialog(Bundle savedInstanceState
) {
61 /// load the custom view to insert in the dialog, between title and
62 WebView webview
= new WebView(getActivity());
63 webview
.loadUrl("file:///android_res/raw/" + getResources().getResourceEntryName(R
.raw
.changelog
) + ".html");
66 AlertDialog
.Builder builder
= new AlertDialog
.Builder(getActivity());
68 Dialog dialog
= builder
.setView(webview
)
69 .setIcon(DisplayUtils
.getSeasonalIconId())
70 //.setTitle(R.string.whats_new)
71 .setPositiveButton(R
.string
.common_ok
,
72 new DialogInterface
.OnClickListener() {
74 public void onClick(DialogInterface dialog
, int which
) {
79 dialog
.setCancelable(getArguments().getBoolean(ARG_CANCELABLE
));
87 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
88 /// load the custom layout
89 View view = inflater.inflate(R.layout.fragment_changelog, container);
90 mEditText = (EditText) view.findViewById(R.id.txt_your_name);
91 getDialog().setTitle(R.string.whats_new);
93 /// read full contents of the change log file (don't make it too big)
94 InputStream changeLogStream = getResources().openRawResource(R.raw.changelog);
95 Scanner scanner = new java.util.Scanner(changeLogStream).useDelimiter("\\A");
96 String text = scanner.hasNext() ? scanner.next() : "";
98 /// make clickable the links in the change log file
99 SpannableString sText = new SpannableString(text);
100 Linkify.addLinks(sText, Linkify.ALL);