Android-x86
Fork
Faire un don

  • R/O
  • HTTP
  • SSH
  • HTTPS

packages-apps-FileManager: Commit

packages/apps/FileManager


Commit MetaInfo

Révision9471f21e6896254fa67c70dce957ef5f8bafbdfe (tree)
l'heure2011-07-03 03:08:18
AuteurJoe Berria <nexesdevelopment@gmai...>
CommiterJoe Berria

Message de Log

added ability to changed bookmark names

Change Summary

Modification

--- a/src/com/nexes/manager/tablet/DirListActivity.java
+++ b/src/com/nexes/manager/tablet/DirListActivity.java
@@ -27,11 +27,9 @@ import android.content.DialogInterface;
2727 import android.preference.PreferenceManager;
2828 import android.app.ListFragment;
2929 import android.app.AlertDialog;
30-import android.view.ContextMenu;
3130 import android.view.View;
3231 import android.view.ViewGroup;
3332 import android.view.LayoutInflater;
34-import android.view.ContextMenu.ContextMenuInfo;
3533 import android.widget.AdapterView;
3634 import android.widget.AdapterView.OnItemLongClickListener;
3735 import android.widget.ListView;
@@ -39,7 +37,6 @@ import android.widget.ImageView;
3937 import android.widget.TextView;
4038 import android.widget.EditText;
4139 import android.widget.ArrayAdapter;
42-import android.widget.AdapterView.AdapterContextMenuInfo;
4340 import android.widget.Toast;
4441
4542 import java.util.ArrayList;
@@ -47,15 +44,16 @@ import java.io.File;
4744
4845 public class DirListActivity extends ListFragment implements OnBookMarkAddListener,
4946 OnItemLongClickListener{
50- private static final String PREF_LIST_KEY = "pref_dirlist";
5147 private static final int BOOKMARK_POS = 6;
5248
5349 private static OnChangeLocationListener mChangeLocList;
5450 private ArrayList<String> mDirList;
51+ private ArrayList<String> mBookmarkNames;
5552 private Context mContext;
5653 private ImageView mLastIndicater = null;
5754 private DirListAdapter mDelegate;
5855 private String mDirListString;
56+ private String mBookmarkString;
5957
6058
6159 public interface OnChangeLocationListener {
@@ -69,10 +67,14 @@ public class DirListActivity extends ListFragment implements OnBookMarkAddListen
6967 String storage = "/" + Environment.getExternalStorageDirectory().getName();
7068 mContext = getActivity();
7169 mDirList = new ArrayList<String>();
70+ mBookmarkNames = new ArrayList<String>();
7271 mDirListString = (PreferenceManager.getDefaultSharedPreferences(mContext))
73- .getString(PREF_LIST_KEY, "");
72+ .getString(SettingsActivity.PREF_LIST_KEY, "");
7473
75- if(mDirListString.length() > 0) {
74+ mBookmarkString = (PreferenceManager.getDefaultSharedPreferences(mContext))
75+ .getString(SettingsActivity.PREF_BOOKNAME_KEY, "");
76+
77+ if (mDirListString.length() > 0) {
7678 String[] l = mDirListString.split(":");
7779
7880 for(String string : l)
@@ -87,12 +89,18 @@ public class DirListActivity extends ListFragment implements OnBookMarkAddListen
8789 mDirList.add(storage + "/" + "Pictures");
8890 mDirList.add("Bookmarks");
8991 }
92+
93+ if (mBookmarkString.length() > 0) {
94+ String[] l = mBookmarkString.split(":");
95+
96+ for(String string : l)
97+ mBookmarkNames.add(string);
98+ }
9099 }
91100
92101 @Override
93102 public void onActivityCreated(Bundle savedInstanceState) {
94103 super.onActivityCreated(savedInstanceState);
95- getView().setBackgroundResource(R.color.gray);
96104
97105 ListView lv = getListView();
98106 lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
@@ -129,18 +137,19 @@ public class DirListActivity extends ListFragment implements OnBookMarkAddListen
129137
130138 @Override
131139 public boolean onItemLongClick(AdapterView<?> list, View view, int pos, long id) {
140+ AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
141+ LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
142+
143+ View v = inflater.inflate(R.layout.input_dialog_layout, null);
144+ final EditText text = (EditText)v.findViewById(R.id.dialog_input);
145+
132146
133147 /* the first two items in our dir list is / and scdard.
134148 * the user should not be able to change the location
135149 * of these two entries. Everything else is fair game */
136150 if (pos > 1 && pos < BOOKMARK_POS) {
137- AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
138- LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
139-
140- View v = inflater.inflate(R.layout.input_dialog_layout, null);
141151 final int position = pos;
142- final EditText text = (EditText)v.findViewById(R.id.dialog_input);
143-
152+
144153 ((TextView)v.findViewById(R.id.dialog_message))
145154 .setText("Change the location of this directory.");
146155
@@ -186,41 +195,55 @@ public class DirListActivity extends ListFragment implements OnBookMarkAddListen
186195
187196 builder.create().show();
188197 return true;
189- }
190198
191- return false;
192- }
193-
194- @Override
195- public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
196- final int pos = ((AdapterContextMenuInfo)menuInfo).position;
197-
198- if(pos <= BOOKMARK_POS)
199- return;
200-
201- new AlertDialog.Builder(mContext)
202- .setTitle("Remove Bookmark " + mDirList.get(pos))
203- .setMessage("Are you sure you want to remove this as a bookmark?")
204- .setPositiveButton("Remove", new DialogInterface.OnClickListener() {
199+ /*manage the users bookmarks, delete or rename*/
200+ } else if (pos > BOOKMARK_POS) {
201+ final int p = pos;
202+ final String bookmark = mBookmarkNames.get(p - (BOOKMARK_POS + 1));
203+
204+ builder.setTitle("Manage bookmark " + bookmark);
205+ builder.setIcon(R.drawable.folder_md);
206+ builder.setView(v);
207+
208+ ((TextView)v.findViewById(R.id.dialog_message))
209+ .setText("Would you like to delete or rename this bookmark?");
210+
211+ text.setText(bookmark);
212+ builder.setPositiveButton("Delete", new DialogInterface.OnClickListener() {
213+
205214 @Override
206215 public void onClick(DialogInterface dialog, int which) {
207- mDirList.remove(pos);
216+ mDirList.remove(p);
217+ mBookmarkNames.remove(p - (BOOKMARK_POS + 1));
218+
208219 buildDirString();
209220 mDelegate.notifyDataSetChanged();
210221 }
211- })
212- .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
222+ });
223+ builder.setNegativeButton("Rename", new DialogInterface.OnClickListener() {
224+
213225 @Override
214226 public void onClick(DialogInterface dialog, int which) {
215- dialog.dismiss();
227+ mBookmarkNames.remove(p - (BOOKMARK_POS + 1));
228+ mBookmarkNames.add(p - (BOOKMARK_POS + 1), text.getText().toString());
229+
230+ buildDirString();
231+ mDelegate.notifyDataSetChanged();
216232 }
217-
218- }).create().show();
233+ });
234+
235+ builder.create().show();
236+ return true;
237+
238+ }
239+ return false;
219240 }
220-
241+
221242 @Override
222243 public void onBookMarkAdd(String path) {
223244 mDirList.add(path);
245+ mBookmarkNames.add(path.substring(path.lastIndexOf("/") + 1));
246+
224247 buildDirString();
225248 mDelegate.notifyDataSetChanged();
226249 }
@@ -229,25 +252,37 @@ public class DirListActivity extends ListFragment implements OnBookMarkAddListen
229252 mChangeLocList = l;
230253 }
231254
232- public void setDirListString(String list) {
233- mDirListString = list;
234- }
255+// public void setDirListString(String list) {
256+// mDirListString = list;
257+// }
235258
236259 public String getDirListString() {
237260 return mDirListString;
238261 }
239262
263+
264+ public String getBookMarkNameString() {
265+ return mBookmarkString;
266+ }
267+
240268 /*
241269 * Builds a string from mDirList to easily save and recall
242270 * from preferences.
243271 */
244272 private void buildDirString() {
273+ int len = mDirList.size();
245274
246- if(mDirListString != null && mDirListString.length() > 0)
275+ if(mDirListString != null && mDirListString.length() > 0) {
247276 mDirListString = "";
277+ mBookmarkString = "";
278+ }
248279
249- for(String l : mDirList)
250- mDirListString += l + ":";
280+ for (int i = 0; i <len; i++) {
281+ mDirListString += mDirList.get(i) + ":";
282+
283+ if (i > BOOKMARK_POS && mBookmarkNames.size() > 0)
284+ mBookmarkString += mBookmarkNames.get(i - (BOOKMARK_POS + 1)) + ":";
285+ }
251286 }
252287
253288
@@ -263,9 +298,7 @@ public class DirListActivity extends ListFragment implements OnBookMarkAddListen
263298 }
264299
265300 @Override
266- public View getView(int position, View view, ViewGroup parent) {
267- String name = mDirList.get(position);
268-
301+ public View getView(int position, View view, ViewGroup parent) {
269302 if(view == null) {
270303 LayoutInflater in = (LayoutInflater)mContext.
271304 getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@@ -321,8 +354,7 @@ public class DirListActivity extends ListFragment implements OnBookMarkAddListen
321354 break;
322355
323356 default:
324- mHolder.mMainText.setText(name.substring(name.lastIndexOf("/") + 1,
325- name.length()));
357+ mHolder.mMainText.setText(mBookmarkNames.get(position - (BOOKMARK_POS + 1)));
326358 mHolder.mIcon.setImageResource(R.drawable.folder_md);
327359 break;
328360 }
--- a/src/com/nexes/manager/tablet/MainActivity.java
+++ b/src/com/nexes/manager/tablet/MainActivity.java
@@ -206,7 +206,7 @@ public class MainActivity extends Activity {
206206
207207 /* read and display the users preferences */
208208 mSettingsListener.onHiddenFilesChanged(mPreferences.getBoolean(SettingsActivity.PREF_HIDDEN_KEY, false));
209- mSettingsListener.onThumbnailChanged(mPreferences.getBoolean(SettingsActivity.PREF_THUMB_KEY, false));
209+ mSettingsListener.onThumbnailChanged(mPreferences.getBoolean(SettingsActivity.PREF_THUMB_KEY, true));
210210 mSettingsListener.onViewChanged(mPreferences.getString(SettingsActivity.PREF_VIEW_KEY, "grid"));
211211 mSettingsListener.onSortingChanged(mPreferences.getString(SettingsActivity.PREF_SORT_KEY, "type"));
212212 }
@@ -314,12 +314,22 @@ public class MainActivity extends Activity {
314314 super.onPause();
315315 String list = ((DirListActivity)getFragmentManager()
316316 .findFragmentById(R.id.list_frag)).getDirListString();
317+ String bookmark = ((DirListActivity)getFragmentManager()
318+ .findFragmentById(R.id.list_frag)).getBookMarkNameString();
319+
317320 String saved = mPreferences.getString(SettingsActivity.PREF_LIST_KEY, "");
321+ String saved_book = mPreferences.getString(SettingsActivity.PREF_BOOKNAME_KEY, "");
318322
319- if(!list.equals(saved)) {
323+ if (!list.equals(saved)) {
320324 SharedPreferences.Editor e = mPreferences.edit();
321325 e.putString(SettingsActivity.PREF_LIST_KEY, list);
322- e.commit();
326+ e.commit();
327+ }
328+
329+ if (!bookmark.equals(saved_book)) {
330+ SharedPreferences.Editor e = mPreferences.edit();
331+ e.putString(SettingsActivity.PREF_BOOKNAME_KEY, bookmark);
332+ e.commit();
323333 }
324334 }
325335 }
--- a/src/com/nexes/manager/tablet/SettingsActivity.java
+++ b/src/com/nexes/manager/tablet/SettingsActivity.java
@@ -24,6 +24,7 @@ import android.preference.PreferenceActivity;
2424 public class SettingsActivity extends PreferenceActivity {
2525 //keys used for preference file
2626 public static final String PREF_LIST_KEY = "pref_dirlist";
27+ public static final String PREF_BOOKNAME_KEY = "pref_bookmarks";
2728 public static final String PREF_HIDDEN_KEY = "pref_hiddenFiles";
2829 public static final String PREF_THUMB_KEY = "pref_thumbnail";
2930 public static final String PREF_VIEW_KEY = "pref_view";
Afficher sur ancien navigateur de dépôt.