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 public static final String TAG
= EditNameDialog
.class.getSimpleName();
44 private String mNewFilename
;
45 private boolean mResult
;
46 private EditNameDialogListener mListener
;
48 static public EditNameDialog
newInstance(String filename
) {
49 EditNameDialog f
= new EditNameDialog();
50 Bundle args
= new Bundle();
51 args
.putString("filename", filename
);
57 public View
onCreateView(LayoutInflater inflater
, ViewGroup container
, Bundle savedInstanceState
) {
58 View v
= inflater
.inflate(R
.layout
.edit_box_dialog
, container
, false
);
60 String currentName
= getArguments().getString("filename");
61 if (currentName
== null
)
64 ((Button
)v
.findViewById(R
.id
.cancel
)).setOnClickListener(this);
65 ((Button
)v
.findViewById(R
.id
.ok
)).setOnClickListener(this);
66 ((TextView
)v
.findViewById(R
.id
.user_input
)).setText(currentName
);
67 ((TextView
)v
.findViewById(R
.id
.user_input
)).requestFocus();
68 getDialog().getWindow().setSoftInputMode(LayoutParams
.SOFT_INPUT_STATE_VISIBLE
);
75 public void onClick(View view
) {
76 switch (view
.getId()) {
78 mNewFilename
= ((TextView
)getView().findViewById(R
.id
.user_input
)).getText().toString();
81 case R
.id
.cancel
: { // fallthought
83 if (mListener
!= null
)
84 mListener
.onDismiss(this);
89 public void setOnDismissListener(EditNameDialogListener listener
) {
93 public String
getNewFilename() {
97 // true if user clicked ok
98 public boolean getResult() {
103 public interface EditNameDialogListener
{
104 public void onDismiss(EditNameDialog dialog
);