FreeRDP
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
com.freerdp.freerdpcore.presentation.BookmarkActivity Class Reference
Inheritance diagram for com.freerdp.freerdpcore.presentation.BookmarkActivity:
Collaboration diagram for com.freerdp.freerdpcore.presentation.BookmarkActivity:

Public Member Functions

void onCreate (Bundle savedInstanceState)
 
void onSharedPreferenceChanged (SharedPreferences sharedPreferences, String key)
 
void onBackPressed ()
 

Static Public Attributes

static final String PARAM_CONNECTION_REFERENCE = "conRef"
 

Detailed Description

Definition at line 40 of file BookmarkActivity.java.

Member Function Documentation

◆ onBackPressed()

void com.freerdp.freerdpcore.presentation.BookmarkActivity.onBackPressed ( )
inline

Definition at line 636 of file BookmarkActivity.java.

637 {
638 // only proceed if we are in the main preferences screen
639 if (current_preferences != PREFERENCES_BOOKMARK)
640 {
641 super.onBackPressed();
642 getPreferenceManager()
643 .getSharedPreferences()
644 .unregisterOnSharedPreferenceChangeListener(this);
645 return;
646 }
647
648 SharedPreferences sharedPreferences = getPreferenceManager().getSharedPreferences();
649 if (!verifySettings(sharedPreferences))
650 {
651 // ask the user if he wants to cancel or continue editing
652 AlertDialog.Builder builder = new AlertDialog.Builder(this);
653 builder.setTitle(R.string.error_bookmark_incomplete_title)
654 .setMessage(R.string.error_bookmark_incomplete)
655 .setPositiveButton(R.string.cancel,
656 new DialogInterface.OnClickListener() {
657 @Override
658 public void onClick(DialogInterface dialog, int which)
659 {
660 finishAndResetBookmark();
661 }
662 })
663 .setNegativeButton(R.string.cont,
664 new DialogInterface.OnClickListener() {
665 @Override
666 public void onClick(DialogInterface dialog, int which)
667 {
668 dialog.cancel();
669 }
670 })
671 .show();
672 }
673 else
674 {
675 // ask the user if he wants to save or cancel editing if a setting
676 // has changed
677 if (new_bookmark || settings_changed)
678 {
679 AlertDialog.Builder builder = new AlertDialog.Builder(this);
680 builder.setTitle(R.string.dlg_title_save_bookmark)
681 .setMessage(R.string.dlg_save_bookmark)
682 .setPositiveButton(
683 R.string.yes,
684 new DialogInterface.OnClickListener() {
685 @Override public void onClick(DialogInterface dialog, int which)
686 {
687 // read shared prefs back to bookmark
688 bookmark.readFromSharedPreferences(
689 getPreferenceManager().getSharedPreferences());
690
691 BookmarkBaseGateway bookmarkGateway;
692 if (bookmark.getType() == BookmarkBase.TYPE_MANUAL)
693 {
694 bookmarkGateway = GlobalApp.getManualBookmarkGateway();
695 // remove any history entry for this
696 // bookmark
697 GlobalApp.getQuickConnectHistoryGateway().removeHistoryItem(
698 bookmark.<ManualBookmark>get().getHostname());
699 }
700 else
701 {
702 assert false;
703 return;
704 }
705
706 // insert or update bookmark and leave
707 // activity
708 if (bookmark.getId() > 0)
709 bookmarkGateway.update(bookmark);
710 else
711 bookmarkGateway.insert(bookmark);
712
713 finishAndResetBookmark();
714 }
715 })
716 .setNegativeButton(R.string.no,
717 new DialogInterface.OnClickListener() {
718 @Override
719 public void onClick(DialogInterface dialog, int which)
720 {
721 finishAndResetBookmark();
722 }
723 })
724 .show();
725 }
726 else
727 {
728 finishAndResetBookmark();
729 }
730 }
731 }

◆ onCreate()

void com.freerdp.freerdpcore.presentation.BookmarkActivity.onCreate ( Bundle  savedInstanceState)
inline

Definition at line 64 of file BookmarkActivity.java.

65 {
66 super.onCreate(savedInstanceState);
67
68 PreferenceManager mgr = getPreferenceManager();
69 // init shared preferences for activity
70 mgr.setSharedPreferencesName("TEMP");
71 mgr.setSharedPreferencesMode(MODE_PRIVATE);
72
73 if (bookmark == null)
74 {
75 // if we have a bookmark id set in the extras we are in edit mode
76 Bundle bundle = getIntent().getExtras();
77 if (bundle != null)
78 {
79 // See if we got a connection reference to a bookmark
80 if (bundle.containsKey(PARAM_CONNECTION_REFERENCE))
81 {
82 String refStr = bundle.getString(PARAM_CONNECTION_REFERENCE);
83 if (ConnectionReference.isManualBookmarkReference(refStr))
84 {
85 bookmark = GlobalApp.getManualBookmarkGateway().findById(
86 ConnectionReference.getManualBookmarkId(refStr));
87 new_bookmark = false;
88 }
89 else if (ConnectionReference.isHostnameReference(refStr))
90 {
91 bookmark = new ManualBookmark();
92 bookmark.<ManualBookmark>get().setLabel(
93 ConnectionReference.getHostname(refStr));
94 bookmark.<ManualBookmark>get().setHostname(
95 ConnectionReference.getHostname(refStr));
96 new_bookmark = true;
97 }
98 else if (ConnectionReference.isFileReference(refStr))
99 {
100 String file = ConnectionReference.getFile(refStr);
101
102 bookmark = new ManualBookmark();
103 bookmark.setLabel(file);
104
105 try
106 {
107 RDPFileParser rdpFile = new RDPFileParser(file);
108 updateBookmarkFromFile((ManualBookmark)bookmark, rdpFile);
109
110 bookmark.setLabel(new File(file).getName());
111 new_bookmark = true;
112 }
113 catch (IOException e)
114 {
115 Log.e(TAG, "Failed reading RDP file", e);
116 }
117 }
118 }
119 }
120
121 // last chance - ensure we really have a valid bookmark
122 if (bookmark == null)
123 bookmark = new ManualBookmark();
124
125 // hide gateway settings if we edit a non-manual bookmark
126 if (current_preferences == PREFERENCES_ADVANCED &&
127 bookmark.getType() != ManualBookmark.TYPE_MANUAL)
128 {
129 PreferenceScreen screen = getPreferenceScreen();
130 screen.removePreference(findPreference("bookmark.enable_gateway"));
131 screen.removePreference(findPreference("bookmark.gateway"));
132 }
133
134 updateH264Preferences();
135
136 // update preferences from bookmark
137 bookmark.writeToSharedPreferences(mgr.getSharedPreferences());
138
139 // no settings changed yet
140 settings_changed = false;
141 }
142
143 // load the requested settings resource
144 if (getIntent() == null || getIntent().getData() == null)
145 {
146 addPreferencesFromResource(R.xml.bookmark_settings);
147 current_preferences = PREFERENCES_BOOKMARK;
148 }
149 else if (getIntent().getData().toString().equals("preferences://screen_settings"))
150 {
151 addPreferencesFromResource(R.xml.screen_settings);
152 current_preferences = PREFERENCES_SCREEN;
153 }
154 else if (getIntent().getData().toString().equals("preferences://performance_flags"))
155 {
156 addPreferencesFromResource(R.xml.performance_flags);
157 current_preferences = PREFERENCES_PERFORMANCE;
158 }
159 else if (getIntent().getData().toString().equals("preferences://screen_settings_3g"))
160 {
161 addPreferencesFromResource(R.xml.screen_settings_3g);
162 current_preferences = PREFERENCES_SCREEN3G;
163 }
164 else if (getIntent().getData().toString().equals("preferences://performance_flags_3g"))
165 {
166 addPreferencesFromResource(R.xml.performance_flags_3g);
167 current_preferences = PREFERENCES_PERFORMANCE3G;
168 }
169 else if (getIntent().getData().toString().equals("preferences://advanced_settings"))
170 {
171 addPreferencesFromResource(R.xml.advanced_settings);
172 current_preferences = PREFERENCES_ADVANCED;
173 }
174 else if (getIntent().getData().toString().equals("preferences://credentials_settings"))
175 {
176 addPreferencesFromResource(R.xml.credentials_settings);
177 current_preferences = PREFERENCES_CREDENTIALS;
178 }
179 else if (getIntent().getData().toString().equals("preferences://gateway_settings"))
180 {
181 addPreferencesFromResource(R.xml.gateway_settings);
182 current_preferences = PREFERENCES_GATEWAY;
183 }
184 else if (getIntent().getData().toString().equals("preferences://debug_settings"))
185 {
186 addPreferencesFromResource(R.xml.debug_settings);
187 current_preferences = PREFERENCES_DEBUG;
188 }
189 else
190 {
191 addPreferencesFromResource(R.xml.bookmark_settings);
192 current_preferences = PREFERENCES_BOOKMARK;
193 }
194
195 // update UI with bookmark data
196 SharedPreferences spref = mgr.getSharedPreferences();
197 initSettings(spref);
198
199 // register for preferences changed notification
200 mgr.getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
201
202 // set the correct component names in our preferencescreen settings
203 setIntentComponentNames();
204
205 updateH264Preferences();
206 }

◆ onSharedPreferenceChanged()

void com.freerdp.freerdpcore.presentation.BookmarkActivity.onSharedPreferenceChanged ( SharedPreferences  sharedPreferences,
String  key 
)
inline

Definition at line 302 of file BookmarkActivity.java.

303 {
304 settings_changed = true;
305 switch (current_preferences)
306 {
307 case PREFERENCES_DEBUG:
308 debugSettingsChanged(sharedPreferences, key);
309 break;
310
311 case PREFERENCES_BOOKMARK:
312 bookmarkSettingsChanged(sharedPreferences, key);
313 break;
314
315 case PREFERENCES_ADVANCED:
316 advancedSettingsChanged(sharedPreferences, key);
317 break;
318
319 case PREFERENCES_CREDENTIALS:
320 credentialsSettingsChanged(sharedPreferences, key);
321 break;
322
323 case PREFERENCES_SCREEN:
324 case PREFERENCES_SCREEN3G:
325 screenSettingsChanged(sharedPreferences, key);
326 break;
327
328 case PREFERENCES_GATEWAY:
329 gatewaySettingsChanged(sharedPreferences, key);
330 break;
331
332 default:
333 break;
334 }
335 }

Field Documentation

◆ PARAM_CONNECTION_REFERENCE

final String com.freerdp.freerdpcore.presentation.BookmarkActivity.PARAM_CONNECTION_REFERENCE = "conRef"
static

Definition at line 42 of file BookmarkActivity.java.


The documentation for this class was generated from the following file: