Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include switch to allow or disallow light filtering from other apps like Twilight or similars #2429

Merged
merged 9 commits into from
Feb 22, 2019
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import android.webkit.WebView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
import android.widget.Toast;
Expand Down Expand Up @@ -113,6 +114,7 @@
import com.owncloud.android.ui.dialog.SslUntrustedCertDialog.OnSslUntrustedCertListener;
import com.owncloud.android.ui.errorhandling.ErrorMessageAdapter;
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.PreferenceUtils;

import java.security.cert.X509Certificate;
import java.util.ArrayList;
Expand Down Expand Up @@ -305,9 +307,15 @@ protected void onCreate(Bundle savedInstanceState) {
/// load user interface
setContentView(R.layout.account_setup);

// Allow or disallow touches with other visible windows
FrameLayout loginLayout = findViewById(R.id.login_layout);
loginLayout.setFilterTouchesWhenObscured(
PreferenceUtils.shouldDisallowTouchesWithOtherVisibleWindows(this)
);

// Set login background color or image
if (!getResources().getBoolean(R.bool.use_login_background_image)) {
findViewById(R.id.login_layout).setBackgroundColor(
loginLayout.setBackgroundColor(
getResources().getColor(R.color.login_background_color)
);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*
* @author David A. Velasco
* @author Christian Schabesberger
* @author David González Verdugo
* Copyright (C) 2019 ownCloud GmbH.
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -40,51 +41,58 @@
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;

import java.util.Formatter;
import java.util.Locale;

import com.owncloud.android.R;
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.PreferenceUtils;

import java.util.Formatter;
import java.util.Locale;


/**
* View containing controls for a {@link MediaPlayer}.
*
*
* Holds buttons "play / pause", "rewind", "fast forward"
* and a progress slider.
*
*
* It synchronizes itself with the state of the
* {@link MediaPlayer}.
*/

public class MediaControlView extends FrameLayout implements OnClickListener, OnSeekBarChangeListener {

private MediaPlayerControl mPlayer;
private Context mContext;
private View mRoot;
private ProgressBar mProgress;
private TextView mEndTime, mCurrentTime;
private boolean mDragging;
private static final int SHOW_PROGRESS = 1;
StringBuilder mFormatBuilder;
Formatter mFormatter;
private ImageButton mPauseButton;
private ImageButton mFfwdButton;
private ImageButton mRewButton;
private MediaPlayerControl mPlayer;
private Context mContext;
private View mRoot;
private ProgressBar mProgress;
private TextView mEndTime, mCurrentTime;
private boolean mDragging;
private static final int SHOW_PROGRESS = 1;
StringBuilder mFormatBuilder;
Formatter mFormatter;
private ImageButton mPauseButton;
private ImageButton mFfwdButton;
private ImageButton mRewButton;

public MediaControlView(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;

FrameLayout.LayoutParams frameParams = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
);
LayoutInflater inflate = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mRoot = inflate.inflate(R.layout.media_control, null);

// Allow or disallow touches with other visible windows
mRoot.setFilterTouchesWhenObscured(
PreferenceUtils.shouldDisallowTouchesWithOtherVisibleWindows(context)
);

initControllerView(mRoot);
addView(mRoot, frameParams);

setFocusable(true);
setFocusableInTouchMode(true);
setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import com.owncloud.android.lib.common.OwnCloudAccount;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.PreferenceUtils;

/**
* Base class to handle setup of the drawer implementation including user switching and avatar fetching and fallback
Expand Down Expand Up @@ -105,8 +106,19 @@ protected void setupDrawer(int menuItemId) {
*/
protected void setupDrawer() {
mDrawerLayout = findViewById(R.id.drawer_layout);

// Allow or disallow touches with other visible windows
mDrawerLayout.setFilterTouchesWhenObscured(
PreferenceUtils.shouldDisallowTouchesWithOtherVisibleWindows(this)
);

mNavigationView = findViewById(R.id.nav_view);

// Allow or disallow touches with other visible windows
mNavigationView.setFilterTouchesWhenObscured(
PreferenceUtils.shouldDisallowTouchesWithOtherVisibleWindows(this)
);

if (mNavigationView != null) {
mDrawerLogo = findViewById(R.id.drawer_logo);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*
* @author David A. Velasco
* @author Christian Schabesberger
* @author David González Verdugo
* Copyright (C) 2019 ownCloud GmbH.
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -40,6 +41,7 @@
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
Expand All @@ -48,26 +50,25 @@
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.common.utils.Log_OC;

import com.owncloud.android.ui.dialog.LoadingDialog;
import com.owncloud.android.utils.FileStorageUtils;

import com.owncloud.android.utils.PreferenceUtils;


/**
* Activity reporting errors occurred when local files uploaded to an ownCloud account with an app
* in version under 1.3.16 where being copied to the ownCloud local folder.
*
*
* Allows the user move the files to the ownCloud local folder. let them unlinked to the remote
* files.
*
*
* Shown when the error notification summarizing the list of errors is clicked by the user.
*/
public class ErrorsWhileCopyingHandlerActivity extends AppCompatActivity
public class ErrorsWhileCopyingHandlerActivity extends AppCompatActivity
implements OnClickListener {

private static final String TAG = ErrorsWhileCopyingHandlerActivity.class.getSimpleName();

public static final String EXTRA_ACCOUNT =
ErrorsWhileCopyingHandlerActivity.class.getCanonicalName() + ".KEY_ACCOUNT";
public static final String EXTRA_LOCAL_PATHS =
Expand Down Expand Up @@ -114,7 +115,13 @@ protected void onCreate(Bundle savedInstanceState) {
appName, appName, appName, appName, mAccount.name);
textView.setText(message);
textView.setMovementMethod(new ScrollingMovementMethod());


// Allow or disallow touches with other visible windows
LinearLayout alertDialogListViewLayout = findViewById(R.id.alertDialogListViewLayout);
alertDialogListViewLayout.setFilterTouchesWhenObscured(
PreferenceUtils.shouldDisallowTouchesWithOtherVisibleWindows(this)
);

/// load the list of local and remote files that failed
ListView listView = findViewById(R.id.list);
if (mLocalPaths != null && mLocalPaths.size() > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
import com.owncloud.android.utils.Extras;
import com.owncloud.android.utils.FileStorageUtils;
import com.owncloud.android.utils.PermissionUtil;
import com.owncloud.android.utils.PreferenceUtils;

import java.io.File;
import java.util.ArrayList;
Expand Down Expand Up @@ -526,10 +527,12 @@ public boolean onPrepareOptionsMenu(Menu menu) {
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();

// Prevent tapjacking
// Allow or disallow touches with other visible windows
View actionBarView = findViewById(R.id.action_bar);
if (actionBarView != null) {
actionBarView.setFilterTouchesWhenObscured(true);
actionBarView.setFilterTouchesWhenObscured(
PreferenceUtils.shouldDisallowTouchesWithOtherVisibleWindows(getApplicationContext())
);
}

inflater.inflate(R.menu.main_menu, menu);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* ownCloud Android client application
*
* @author Shashvat Kedia
* @author David González Verdugo
* Copyright (C) 2019 ownCloud GmbH.
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -40,6 +41,7 @@
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;

import com.owncloud.android.R;
import com.owncloud.android.datamodel.OCFile;
Expand All @@ -52,9 +54,10 @@
import com.owncloud.android.operations.common.SyncOperation;
import com.owncloud.android.syncadapter.FileSyncAdapter;
import com.owncloud.android.ui.dialog.CreateFolderDialogFragment;
import com.owncloud.android.ui.errorhandling.ErrorMessageAdapter;
import com.owncloud.android.ui.fragment.FileFragment;
import com.owncloud.android.ui.fragment.OCFileListFragment;
import com.owncloud.android.ui.errorhandling.ErrorMessageAdapter;
import com.owncloud.android.utils.PreferenceUtils;

import java.util.ArrayList;

Expand Down Expand Up @@ -84,6 +87,12 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.files_folder_picker); // beware - inflated in other activities too

// Allow or disallow touches with other visible windows
LinearLayout filesFolderPickerLayout = findViewById(R.id.filesFolderPickerLayout);
filesFolderPickerLayout.setFilterTouchesWhenObscured(
PreferenceUtils.shouldDisallowTouchesWithOtherVisibleWindows(this)
);

if (savedInstanceState == null) {
createFragments();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*
* @author David A. Velasco
* @author Christian Schabesberger
* @author David González Verdugo
* Copyright (C) 2019 ownCloud GmbH.
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -31,46 +32,54 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.owncloud.android.R;
import com.owncloud.android.utils.PreferenceUtils;


/**
* Activity showing a text message and, optionally, a couple list of single or paired text strings.
*
*
* Added to show explanations for notifications when the user clicks on them, and there no place
* better to show them.
*/
public class GenericExplanationActivity extends AppCompatActivity {
public class GenericExplanationActivity extends AppCompatActivity {

public static final String EXTRA_LIST = GenericExplanationActivity.class.getCanonicalName() +
".EXTRA_LIST";
public static final String EXTRA_LIST_2 = GenericExplanationActivity.class.getCanonicalName() +
".EXTRA_LIST_2";
public static final String MESSAGE = GenericExplanationActivity.class.getCanonicalName() +
".MESSAGE";


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

Intent intent = getIntent();
String message = intent.getStringExtra(MESSAGE);
String message = intent.getStringExtra(MESSAGE);
ArrayList<String> list = intent.getStringArrayListExtra(EXTRA_LIST);
ArrayList<String> list2 = intent.getStringArrayListExtra(EXTRA_LIST_2);

setContentView(R.layout.generic_explanation);

if (message != null) {
TextView textView = findViewById(R.id.message);
textView.setText(message);
textView.setMovementMethod(new ScrollingMovementMethod());
}


// Allow or disallow touches with other visible windows
LinearLayout alertDialogListViewLayout = findViewById(R.id.alertDialogListViewLayout);
alertDialogListViewLayout.setFilterTouchesWhenObscured(
PreferenceUtils.shouldDisallowTouchesWithOtherVisibleWindows(this)
);

ListView listView = findViewById(R.id.list);
if (list != null && list.size() > 0) {
//ListAdapter adapter = new ArrayAdapter<String>(this,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*
* @author David A. Velasco
* @author Christian Schabesberger
* @author David González Verdugo
* Copyright (C) 2019 ownCloud GmbH.
*
* This program is free software: you can redistribute it and/or modify
Expand All @@ -25,18 +26,19 @@
import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import androidx.appcompat.app.ActionBar;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;

import android.widget.LinearLayout;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import com.owncloud.android.R;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.ui.fragment.LocalFileListFragment;
import com.owncloud.android.utils.PreferenceUtils;

import java.io.File;

Expand Down Expand Up @@ -99,6 +101,13 @@ public void onCreate(Bundle savedInstanceState) {

// inflate and set the layout view
setContentView(R.layout.files_folder_picker); // beware - inflated in other activities too

// Allow or disallow touches with other visible windows
LinearLayout filesFolderPickerLayout = findViewById(R.id.filesFolderPickerLayout);
filesFolderPickerLayout.setFilterTouchesWhenObscured(
PreferenceUtils.shouldDisallowTouchesWithOtherVisibleWindows(this)
);

if (savedInstanceState == null) {
createFragments();
}
Expand Down
Loading