OC-2332: rewrite getAvailableRemotePath from UpdateFileOperation, using ExistenceCehe...
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / dialog / ChangelogDialog.java
1 /* ownCloud Android client application
2 * Copyright (C) 2012-2013 ownCloud Inc.
3 *
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.
7 *
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.
12 *
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/>.
15 *
16 */
17
18 package com.owncloud.android.ui.dialog;
19
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;
25
26 import com.actionbarsherlock.app.SherlockDialogFragment;
27 import com.owncloud.android.R;
28
29
30 /**
31 * Dialog to show the contents of res/raw/CHANGELOG.txt
32 */
33 public class ChangelogDialog extends SherlockDialogFragment {
34
35 private static final String ARG_CANCELABLE = ChangelogDialog.class.getCanonicalName() + ".ARG_CANCELABLE";
36
37
38 /**
39 * Public factory method to get dialog instances.
40 *
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.
43 */
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);
49 return fragment;
50 }
51
52
53 /**
54 * {@inheritDoc}
55 */
56 @Override
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");
61
62 /// build the dialog
63 AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
64
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() {
70 @Override
71 public void onClick(DialogInterface dialog, int which) {
72 dialog.dismiss();
73 }
74 }).create();
75
76 dialog.setCancelable(getArguments().getBoolean(ARG_CANCELABLE));
77 return dialog;
78 }
79
80 /**
81 * {@inheritDoc}
82 *-/
83 @Override
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);
89
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() : "";
94
95 /// make clickable the links in the change log file
96 SpannableString sText = new SpannableString(text);
97 Linkify.addLinks(sText, Linkify.ALL);
98
99 return view;
100 }
101 */
102 }
103
104