1 /* ownCloud Android client application
2 * Copyright (C) 2011 Bartek Przybylski
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 package com
.owncloud
.android
.ui
.dialog
;
22 import android
.os
.Bundle
;
23 import android
.view
.LayoutInflater
;
24 import android
.view
.View
;
25 import android
.view
.ViewGroup
;
26 import android
.view
.View
.OnClickListener
;
27 import android
.view
.WindowManager
.LayoutParams
;
28 import android
.widget
.Button
;
29 import android
.widget
.TextView
;
31 import com
.actionbarsherlock
.app
.SherlockDialogFragment
;
32 import com
.owncloud
.android
.R
;
36 * Dialog to request the user about a certificate that could not be validated with the certificates store in the system.
38 * @author Bartek Przybylski
40 public class EditNameDialog
extends SherlockDialogFragment
implements OnClickListener
{
42 private String mNewFilename
;
43 private boolean mResult
;
44 private EditNameDialogListener mListener
;
46 static public EditNameDialog
newInstance(String filename
) {
47 EditNameDialog f
= new EditNameDialog();
48 Bundle args
= new Bundle();
49 args
.putString("filename", filename
);
55 public View
onCreateView(LayoutInflater inflater
, ViewGroup container
, Bundle savedInstanceState
) {
56 View v
= inflater
.inflate(R
.layout
.edit_box_dialog
, container
, false
);
58 String currentName
= getArguments().getString("filename");
59 if (currentName
== null
)
62 ((Button
)v
.findViewById(R
.id
.cancel
)).setOnClickListener(this);
63 ((Button
)v
.findViewById(R
.id
.ok
)).setOnClickListener(this);
64 ((TextView
)v
.findViewById(R
.id
.user_input
)).setText(currentName
);
65 ((TextView
)v
.findViewById(R
.id
.user_input
)).requestFocus();
66 getDialog().getWindow().setSoftInputMode(LayoutParams
.SOFT_INPUT_STATE_VISIBLE
);
73 public void onClick(View view
) {
74 switch (view
.getId()) {
76 mNewFilename
= ((TextView
)getView().findViewById(R
.id
.user_input
)).getText().toString();
79 case R
.id
.cancel
: { // fallthought
81 if (mListener
!= null
)
82 mListener
.onDismiss(this);
87 public void setOnDismissListener(EditNameDialogListener listener
) {
91 public String
getNewFilename() {
95 // true if user clicked ok
96 public boolean getResult() {
101 public interface EditNameDialogListener
{
102 public void onDismiss(EditNameDialog dialog
);