Add Samsung DeX support

This commit is contained in:
Aleksei Kliuev 2017-09-11 14:03:30 +03:00
parent e6d66d9d81
commit 5931e61ade
18 changed files with 126 additions and 64 deletions

View File

@ -29,9 +29,13 @@ Thumbs.db
*.iml
.idea
#.idea/workspace.xml - remove # and delete .idea if it better suit your needs.
.gradle
build/
/.gradle
/.idea/
/local.properties
build
*.iml
#NDK
obj/
jniLibs/

View File

@ -1,32 +1,22 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion = rootProject.ext.compileSdk
buildToolsVersion = rootProject.ext.buildToolsVersion
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.freerdp.afreerdp"
minSdkVersion rootProject.ext.minSdk
targetSdkVersion rootProject.ext.targetSdk
minSdkVersion 20
targetSdkVersion 25
vectorDrawables.useSupportLibrary = true
versionCode = rootProject.ext.versionCode
versionName = rootProject.ext.versionName
versionCode 1
versionName "1"
}
signingConfigs {
release {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD
storeType "jks"
}
}
buildTypes {
release {
minifyEnabled false
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
debug {

View File

@ -7,14 +7,19 @@
<application
android:name="com.freerdp.afreerdp.application.GlobalApp"
android:icon="@drawable/icon_launcher_freerdp"
android:label="aFreeRDP">
android:label="aFreeRDP"
android:resizeableActivity="true">
<!-- Main activity -->
<activity
android:name="com.freerdp.freerdpcore.presentation.HomeActivity"
android:alwaysRetainTaskState="true"
android:label="@string/app_title"
android:theme="@style/Theme.Main">
android:theme="@style/Theme.Main"
android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|density|screenLayout">
<intent-filter android:label="@string/app_title">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
@ -93,6 +98,8 @@
android:name="com.freerdp.freerdpcore.services.FreeRDPSuggestionProvider"
android:authorities="com.freerdp.afreerdp.services.freerdpsuggestionprovider"></provider>
<meta-data android:name="com.samsung.android.keepalive.density" android:value="true"/>
</application>
</manifest>

View File

@ -7,39 +7,18 @@ if (file.canRead()) {
def getVersionName = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags'
standardOutput = stdout
}
return stdout.toString().trim()
}
ext {
versionCode = properties.get('VERSION', "10").toInteger()
minSdk = properties.get('MIN_SDK', "14").toInteger()
targetSdk = properties.get('TARGET_SDK', "25").toInteger()
compileSdk = properties.get('COMPILE_SDK', "25").toInteger()
buildToolsVersion = properties.get('BUILD_TOOLS', "25.0.2")
versionName = properties.get('VERSION_NAME', getVersionName())
println '----------------- Project configuration -------------------'
println 'VERSION: ' + versionCode
println 'MIN_SDK: ' + minSdk
println 'TARGET_SDK: ' + targetSdk
println 'COMPILE_SDK: ' + compileSdk
println 'BUILD_TOOLS: ' + buildToolsVersion
println 'VERSION_NAME: ' + versionName
println 'RELEASE_STORE_FILE: '+ RELEASE_STORE_FILE
println 'RELEASE_KEY_ALIAS: '+ RELEASE_KEY_ALIAS
println '-----------------------------------------------------------'
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.android.tools.build:gradle:2.3.1'
}
}

View File

@ -1,15 +1,15 @@
apply plugin: 'com.android.library'
android {
compileSdkVersion = rootProject.ext.compileSdk
buildToolsVersion = rootProject.ext.buildToolsVersion
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion rootProject.ext.minSdk
targetSdkVersion rootProject.ext.targetSdk
minSdkVersion 20
targetSdkVersion 25
vectorDrawables.useSupportLibrary = true
versionCode = rootProject.ext.versionCode
versionName = rootProject.ext.versionName
versionCode 1
versionName "1"
}
buildTypes {

View File

@ -18,8 +18,8 @@
android:smallScreens="true"
android:xlargeScreens="true" />
<application android:theme="@style/Theme.Main">
<application android:theme="@style/Theme.Main" android:resizeableActivity="true" >
<meta-data android:name="com.samsung.android.keepalive.density" android:value="true"/>
<!-- Activity to create shortcuts -->
<activity
android:name=".presentation.ShortcutsActivity"
@ -67,9 +67,10 @@
android:windowSoftInputMode="stateHidden" />
<activity
android:name=".presentation.SessionActivity"
android:configChanges="orientation|keyboardHidden|screenSize|keyboard"
android:theme="@style/Theme.Main"
android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|density|screenLayout"
android:windowSoftInputMode="adjustResize">
<!--android:configChanges="orientation|keyboardHidden|screenSize|keyboard"-->
<intent-filter>
<action android:name="android.intent.action.VIEW" />

View File

@ -106,7 +106,7 @@ public class GlobalApp extends Application implements LibFreeRDP.EventListener {
static public void freeSession(long instance) {
if (GlobalApp.sessionMap.containsKey(instance)) {
GlobalApp.sessionMap.remove(instance);
LibFreeRDP.freeInstance(instance);
//LibFreeRDP.freeInstance(instance);
}
}

View File

@ -81,13 +81,15 @@ public class ApplicationSettingsActivity extends AppCompatPreferenceActivity {
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
final String clientNameKey = getString(R.string.preference_key_client_name);
if (isAdded()) {
final String clientNameKey = getString(R.string.preference_key_client_name);
get(getActivity());
if (key.equals(clientNameKey)) {
final String clientNameValue = sharedPreferences.getString(clientNameKey, "");
EditTextPreference pref = (EditTextPreference) findPreference(clientNameKey);
pref.setText(clientNameValue);
get(getActivity());
if (key.equals(clientNameKey)) {
final String clientNameValue = sharedPreferences.getString(clientNameKey, "");
EditTextPreference pref = (EditTextPreference) findPreference(clientNameKey);
pref.setText(clientNameValue);
}
}
}
}
@ -203,6 +205,11 @@ public class ApplicationSettingsActivity extends AppCompatPreferenceActivity {
return preferences.getBoolean(context.getString(R.string.preference_key_ui_hide_status_bar), false);
}
public static boolean getHideActionBar(Context context) {
SharedPreferences preferences = get(context);
return preferences.getBoolean(context.getString(R.string.preference_key_ui_hide_action_bar), false);
}
public static boolean getAcceptAllCertificates(Context context) {
SharedPreferences preferences = get(context);
return preferences.getBoolean(context.getString(R.string.preference_key_accept_certificates), false);

View File

@ -12,6 +12,7 @@ package com.freerdp.freerdpcore.presentation;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
@ -56,6 +57,7 @@ public class HomeActivity extends AppCompatActivity {
private PlaceholderBookmark addBookmarkPlaceholder;
private String sectionLabelBookmarks;
View mDecor;
@Override
public void onCreate(Bundle savedInstanceState) {
@ -63,6 +65,9 @@ public class HomeActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.home);
mDecor = getWindow().getDecorView();
mDecor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
long heapSize = Runtime.getRuntime().maxMemory();
Log.i(TAG, "Max HeapSize: " + heapSize);
Log.i(TAG, "App data folder: " + getFilesDir().toString());
@ -149,6 +154,14 @@ public class HomeActivity extends AppCompatActivity {
});
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
// ignore orientation/keyboard change
super.onConfigurationChanged(newConfig);
mDecor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
@Override
public boolean onSearchRequested() {
superBarEditText.requestFocus();

View File

@ -17,6 +17,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
@ -35,6 +36,7 @@ import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.View;
import android.view.ViewConfiguration;
@ -114,6 +116,7 @@ public class SessionActivity extends AppCompatActivity implements
private int discardedMoveEvents = 0;
private ClipboardManagerProxy mClipboardManager;
private boolean callbackDialogResult;
View mDecor;
private void createDialogs() {
// build verify certificate dialog
@ -199,7 +202,7 @@ public class SessionActivity extends AppCompatActivity implements
}
this.setContentView(R.layout.session);
if (hasHardwareMenuButton()) {
if (hasHardwareMenuButton() || ApplicationSettingsActivity.getHideActionBar(this)) {
this.getSupportActionBar().hide();
} else
this.getSupportActionBar().show();
@ -297,6 +300,9 @@ public class SessionActivity extends AppCompatActivity implements
mClipboardManager = ClipboardManagerProxy.getClipboardManager(this);
mClipboardManager.addClipboardChangedListener(this);
mDecor = getWindow().getDecorView();
mDecor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
@Override
@ -353,6 +359,7 @@ public class SessionActivity extends AppCompatActivity implements
// free session
GlobalApp.freeSession(session.getInstance());
session = null;
}
@ -373,6 +380,8 @@ public class SessionActivity extends AppCompatActivity implements
// apply loaded keyboards
keyboardView.setKeyboard(specialkeysKeyboard);
modifiersKeyboardView.setKeyboard(modifiersKeyboard);
mDecor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
private void processIntent(Intent intent) {
@ -482,6 +491,8 @@ public class SessionActivity extends AppCompatActivity implements
sessionView.onSurfaceChange(session);
scrollView.requestLayout();
keyboardMapper.reset(this);
mDecor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
private void hideSoftInput() {
@ -1092,6 +1103,23 @@ public class SessionActivity extends AppCompatActivity implements
scrollView.scrollTo(0, 0);
}
@Override
public boolean onGenericMotionEvent(MotionEvent e) {
super.onGenericMotionEvent(e);
switch (e.getAction()) {
case MotionEvent.ACTION_SCROLL:
final float vScroll = e.getAxisValue(MotionEvent.AXIS_VSCROLL);
if (vScroll < 0) {
LibFreeRDP.sendCursorEvent(session.getInstance(), 0, 0, Mouse.getScrollEvent(this, false));
}
if (vScroll > 0) {
LibFreeRDP.sendCursorEvent(session.getInstance(), 0, 0, Mouse.getScrollEvent(this, true));
}
break;
}
return true;
}
// ****************************************************************************
// ClipboardManagerProxy.OnClipboardChangedListener
@Override

View File

@ -18,14 +18,17 @@ import android.graphics.RectF;
import android.graphics.drawable.BitmapDrawable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.View;
import com.freerdp.freerdpcore.application.SessionState;
import com.freerdp.freerdpcore.services.LibFreeRDP;
import com.freerdp.freerdpcore.utils.DoubleGestureDetector;
import com.freerdp.freerdpcore.utils.GestureDetector;
import com.freerdp.freerdpcore.utils.Mouse;
import java.util.Stack;
@ -49,6 +52,7 @@ public class SessionView extends View {
private Matrix invScaleMatrix;
private RectF invalidRegionF;
private GestureDetector gestureDetector;
private SessionState currentSession;
//private static final String TAG = "FreeRDP.SessionView";
private DoubleGestureDetector doubleGestureDetector;
@ -76,6 +80,8 @@ public class SessionView extends View {
scaleMatrix = new Matrix();
invScaleMatrix = new Matrix();
invalidRegionF = new RectF();
setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
public void setScaleGestureDetector(ScaleGestureDetector scaleGestureDetector) {
@ -110,6 +116,7 @@ public class SessionView extends View {
setMinimumHeight(height);
requestLayout();
currentSession = session;
}
public float getZoom() {
@ -281,8 +288,18 @@ public class SessionView extends View {
// send single click
MotionEvent mappedEvent = mapTouchEvent(e);
sessionViewListener.onSessionViewBeginTouch();
sessionViewListener.onSessionViewLeftTouch((int) mappedEvent.getX(), (int) mappedEvent.getY(), true);
sessionViewListener.onSessionViewLeftTouch((int) mappedEvent.getX(), (int) mappedEvent.getY(), false);
switch (e.getButtonState()) {
case MotionEvent.BUTTON_PRIMARY:
sessionViewListener.onSessionViewLeftTouch((int) mappedEvent.getX(), (int) mappedEvent.getY(), true);
sessionViewListener.onSessionViewLeftTouch((int) mappedEvent.getX(), (int) mappedEvent.getY(), false);
break;
case MotionEvent.BUTTON_SECONDARY:
LibFreeRDP.sendCursorEvent(currentSession.getInstance(),
(int) mappedEvent.getX(), (int) mappedEvent.getY(), Mouse.getRightButtonEvent(getContext(), true));
LibFreeRDP.sendCursorEvent(currentSession.getInstance(),
(int) mappedEvent.getX(), (int) mappedEvent.getY(), Mouse.getRightButtonEvent(getContext(), false));
break;
}
sessionViewListener.onSessionViewEndTouch();
return true;
}

View File

@ -122,6 +122,7 @@
<string name="settings_password_empty">nicht gesetzt</string>
<string name="settings_cat_ui">Benutzeroberfläche</string>
<string name="settings_ui_hide_status_bar">verstecke Statusleiste</string>
<string name="settings_ui_hide_action_bar">Aktionsleiste ausblenden</string>
<string name="settings_ui_hide_zoom_controls">verstecke Zoom Tasten</string>
<string name="settings_ui_swap_mouse_buttons">Vertausche Maustasten</string>
<string name="settings_ui_invert_scrolling">Invertiere Bildlauf</string>

View File

@ -123,6 +123,7 @@
<string name="settings_password_empty">no configurado</string>
<string name="settings_cat_ui">Interfaze Usuario</string>
<string name="settings_ui_hide_status_bar">Ocultar barra de estado</string>
<string name="settings_ui_hide_action_bar">\"Ocultar barra de acción\"</string>
<string name="settings_ui_hide_zoom_controls">Ocultar controles de zoom</string>
<string name="settings_ui_swap_mouse_buttons">Intercambiar botones del mouse</string>
<string name="settings_ui_invert_scrolling">invertir desplazamiento</string>

View File

@ -122,6 +122,7 @@
<string name="settings_password_empty">"Valeur non définie"</string>
<string name="settings_cat_ui">"Interface utilisateur"</string>
<string name="settings_ui_hide_status_bar">"Masquer la barre d'état"</string>
<string name="settings_ui_hide_action_bar">\"Masquer la barre d\'action\"</string>
<string name="settings_ui_hide_zoom_controls">"Masquer les contrôles zoom"</string>
<string name="settings_ui_swap_mouse_buttons">"Inverser les boutons de la souris"</string>
<string name="settings_ui_invert_scrolling">"Inverser le défilement de la souris"</string>

View File

@ -123,6 +123,7 @@
<string name="settings_password_empty">Niet ingesteld</string>
<string name="settings_cat_ui">Gebruikersinterface</string>
<string name="settings_ui_hide_status_bar">Verberg statusbalk</string>
<string name="settings_ui_hide_action_bar">Verkeersbalk verbergen</string>
<string name="settings_ui_hide_zoom_controls">Verberg Zoom Controls</string>
<string name="settings_ui_swap_mouse_buttons">Wissel muisknoppen</string>
<string name="settings_ui_invert_scrolling">Scrollen omkeren</string>

View File

@ -122,6 +122,7 @@
<string name="settings_password_empty">未设置</string>
<string name="settings_cat_ui">用户界面</string>
<string name="settings_ui_hide_status_bar">隐藏状态栏</string>
<string name="settings_ui_hide_action_bar">隱藏操作欄</string>
<string name="settings_ui_hide_zoom_controls">隐藏缩放控件</string>
<string name="settings_ui_swap_mouse_buttons">交换鼠标左右键</string>
<string name="settings_ui_invert_scrolling">翻转滚动</string>

View File

@ -163,6 +163,7 @@
<string name="settings_password_empty">not set</string>
<string name="settings_cat_ui">User Interface</string>
<string name="settings_ui_hide_status_bar">Hide Status Bar</string>
<string name="settings_ui_hide_action_bar">Hide Action Bar</string>
<string name="settings_ui_hide_zoom_controls">Hide Zoom Controls</string>
<string name="settings_ui_swap_mouse_buttons">Swap Mouse Buttons</string>
<string name="settings_ui_invert_scrolling">Invert Scrolling</string>
@ -224,6 +225,7 @@
<string name="preference_key_ui_invert_scrolling" translatable="false">ui.invert_scrolling</string>
<string name="preference_key_ui_swap_mouse_buttons" translatable="false">ui.swap_mouse_buttons</string>
<string name="preference_key_ui_hide_zoom_controls" translatable="false">ui.hide_zoom_controls</string>
<string name="preference_key_ui_hide_action_bar" translatable="false">ui.hide_action_bar</string>
<string-array name="debug_array" translatable="false">
<item>OFF</item>
<item>FATAL</item>

View File

@ -1,21 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceScreen xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference
android:defaultValue="true"
android:key="@string/preference_key_ui_hide_status_bar"
android:title="@string/settings_ui_hide_status_bar" />
<CheckBoxPreference
android:defaultValue="true"
android:key="@string/preference_key_ui_hide_zoom_controls"
android:title="@string/settings_ui_hide_zoom_controls" />
<CheckBoxPreference
android:key="@string/preference_key_ui_swap_mouse_buttons"
android:title="@string/settings_ui_swap_mouse_buttons" />
<CheckBoxPreference
android:defaultValue="true"
android:key="@string/preference_key_ui_invert_scrolling"
android:title="@string/settings_ui_invert_scrolling" />
<CheckBoxPreference
android:key="@string/preference_key_ui_auto_scroll_touchpointer"
android:title="@string/settings_ui_auto_scroll_touchpointer" />
<CheckBoxPreference
android:defaultValue="true"
android:key="@string/preference_key_ui_ask_on_exit"
android:title="@string/settings_ui_ask_on_exit" />
<CheckBoxPreference
android:defaultValue="true"
android:key="@string/preference_key_ui_hide_action_bar"
android:title="@string/settings_ui_hide_action_bar" />
</PreferenceScreen>