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