import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
+import android.preference.PreferenceManager;
+import android.preference.PreferenceScreen;
import android.util.Log;
+import android.view.View;
import com.freerdp.freerdpcore.R;
import com.freerdp.freerdpcore.application.GlobalApp;
import com.freerdp.freerdpcore.domain.ConnectionReference;
import com.freerdp.freerdpcore.domain.ManualBookmark;
import com.freerdp.freerdpcore.services.BookmarkBaseGateway;
+import com.freerdp.freerdpcore.services.LibFreeRDP;
import com.freerdp.freerdpcore.utils.RDPFileParser;
import java.io.File;
private static boolean settings_changed = false;
private static boolean new_bookmark = false;
private int current_preferences;
-
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ PreferenceManager mgr = getPreferenceManager();
// init shared preferences for activity
- getPreferenceManager().setSharedPreferencesName("TEMP");
- getPreferenceManager().setSharedPreferencesMode(MODE_PRIVATE);
+ mgr.setSharedPreferencesName("TEMP");
+ mgr.setSharedPreferencesMode(MODE_PRIVATE);
if (bookmark == null) {
// if we have a bookmark id set in the extras we are in edit mode
// hide gateway settings if we edit a non-manual bookmark
if (current_preferences == PREFERENCES_ADVANCED
&& bookmark.getType() != ManualBookmark.TYPE_MANUAL) {
- getPreferenceScreen().removePreference(
- findPreference("bookmark.enable_gateway"));
- getPreferenceScreen().removePreference(
- findPreference("bookmark.gateway"));
+ PreferenceScreen screen = getPreferenceScreen();
+ screen.removePreference(findPreference("bookmark.enable_gateway"));
+ screen.removePreference(findPreference("bookmark.gateway"));
}
+ updateH264Preferences();
+
// update preferences from bookmark
- bookmark.writeToSharedPreferences(getPreferenceManager()
- .getSharedPreferences());
+ bookmark.writeToSharedPreferences(mgr.getSharedPreferences());
// no settings changed yet
settings_changed = false;
}
// update UI with bookmark data
- SharedPreferences spref = getPreferenceManager().getSharedPreferences();
+ SharedPreferences spref = mgr.getSharedPreferences();
initSettings(spref);
// register for preferences changed notification
- getPreferenceManager().getSharedPreferences()
- .registerOnSharedPreferenceChangeListener(this);
+ mgr.getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
// set the correct component names in our preferencescreen settings
setIntentComponentNames();
+
+ updateH264Preferences();
+ }
+
+ private void updateH264Preferences() {
+ if (!LibFreeRDP.hasH264Support()) {
+ final int preferenceIdList[] = {
+ R.string.preference_key_h264,
+ R.string.preference_key_h264_3g
+ };
+
+ PreferenceManager mgr = getPreferenceManager();
+ for (int id : preferenceIdList) {
+ final String key = getString(id);
+ Preference preference = mgr.findPreference(key);
+ if (preference != null) {
+ preference.setEnabled(false);
+ }
+ }
+ }
}
private void updateBookmarkFromFile(ManualBookmark bookmark,
}
}
}
-
}
public class LibFreeRDP {
private static final String TAG = "LibFreeRDP";
private static EventListener listener;
+ private static boolean mHasH264 = true;
static {
+ final String h264 = "openh264";
final String[] libraries = {
- "openh264", "freerdp-openssl", "jpeg", "winpr2",
+ h264, "freerdp-openssl", "jpeg", "winpr2",
"freerdp2", "freerdp-client2", "freerdp-android2"};
final String LD_PATH = System.getProperty("java.library.path");
System.loadLibrary(lib);
} catch (UnsatisfiedLinkError e) {
Log.e(TAG, "Failed to load library " + lib + ": " + e.toString());
+ if (lib.equals(h264)) {
+ mHasH264 = false;
+ }
}
}
}
+ public static boolean hasH264Support() {
+ return mHasH264;
+ }
+
private static native String freerdp_get_jni_version();
private static native String freerdp_get_version();
final String clientName = ApplicationSettingsActivity.getClientName(context);
if (!clientName.isEmpty()) {
- args.add("/client-hostname:\""+clientName+"\"");
+ args.add("/client-hostname:\"" + clientName + "\"");
}
String certName = "";
if (bookmark.getType() != BookmarkBase.TYPE_MANUAL) {
final String clientName = ApplicationSettingsActivity.getClientName(context);
if (!clientName.isEmpty()) {
- args.add("/client-hostname:\""+clientName+"\"");
+ args.add("/client-hostname:\"" + clientName + "\"");
}
// Parse hostname and port. Set to 'v' argument