mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 17:46:37 +03:00
always use window variable
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
parent
e9f524f218
commit
009762cfd0
9 changed files with 40 additions and 24 deletions
|
@ -24,6 +24,7 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.PowerManager;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.owncloud.android.MainApp;
|
||||
|
@ -67,11 +68,12 @@ public class PassCodeManager {
|
|||
private PassCodeManager() {}
|
||||
|
||||
public void onActivityCreated(Activity activity) {
|
||||
if (activity.getWindow() != null) {
|
||||
Window window = activity.getWindow();
|
||||
if (window != null) {
|
||||
if (passCodeIsEnabled() || deviceCredentialsAreEnabled(activity)) {
|
||||
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
||||
} else {
|
||||
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,8 +69,9 @@ public class ExternalSiteWebView extends FileActivity {
|
|||
showSidebar = extras.getBoolean(EXTRA_SHOW_SIDEBAR);
|
||||
|
||||
// show progress
|
||||
if (getWindow() != null) {
|
||||
getWindow().requestFeature(Window.FEATURE_PROGRESS);
|
||||
Window window = getWindow();
|
||||
if (window != null) {
|
||||
window.requestFeature(Window.FEATURE_PROGRESS);
|
||||
}
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
|
|
@ -34,6 +34,7 @@ import android.text.TextWatcher;
|
|||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.Window;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
|
@ -99,8 +100,7 @@ public class PassCodeActivity extends AppCompatActivity {
|
|||
mPassCodeEditTexts[0].setTextColor(elementColor);
|
||||
mPassCodeEditTexts[0].getBackground().setColorFilter(elementColor, PorterDuff.Mode.SRC_ATOP);
|
||||
mPassCodeEditTexts[0].requestFocus();
|
||||
getWindow().setSoftInputMode(android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
||||
|
||||
|
||||
mPassCodeEditTexts[1] = findViewById(R.id.txt1);
|
||||
mPassCodeEditTexts[1].setTextColor(elementColor);
|
||||
mPassCodeEditTexts[1].getBackground().setColorFilter(elementColor, PorterDuff.Mode.SRC_ATOP);
|
||||
|
@ -113,8 +113,9 @@ public class PassCodeActivity extends AppCompatActivity {
|
|||
mPassCodeEditTexts[3].setTextColor(elementColor);
|
||||
mPassCodeEditTexts[3].getBackground().setColorFilter(elementColor, PorterDuff.Mode.SRC_ATOP);
|
||||
|
||||
if (getWindow() != null) {
|
||||
getWindow().setSoftInputMode(android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
||||
Window window = getWindow();
|
||||
if (window != null) {
|
||||
window.setSoftInputMode(android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
||||
}
|
||||
|
||||
if (ACTION_CHECK.equals(getIntent().getAction())) {
|
||||
|
|
|
@ -55,6 +55,7 @@ import android.view.MenuInflater;
|
|||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.webkit.URLUtil;
|
||||
|
||||
import com.owncloud.android.BuildConfig;
|
||||
|
@ -777,19 +778,20 @@ public class Preferences extends PreferenceActivity
|
|||
actionBar.setHomeAsUpIndicator(ThemeUtils.tintDrawable(backArrow, ThemeUtils.fontColor(this)));
|
||||
}
|
||||
|
||||
if (getWindow() != null) {
|
||||
getWindow().getDecorView().setBackgroundDrawable(new ColorDrawable(ResourcesCompat
|
||||
Window window = getWindow();
|
||||
if (window != null) {
|
||||
window.getDecorView().setBackgroundDrawable(new ColorDrawable(ResourcesCompat
|
||||
.getColor(getResources(), R.color.background_color, null)));
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
getWindow().setStatusBarColor(ThemeUtils.primaryDarkColor(this));
|
||||
window.setStatusBarColor(ThemeUtils.primaryDarkColor(this));
|
||||
}
|
||||
|
||||
// For adding content description tag to a title field in the action bar
|
||||
int actionBarTitleId = getResources().getIdentifier("action_bar_title", "id", "android");
|
||||
View actionBarTitleView = getWindow().getDecorView().findViewById(actionBarTitleId);
|
||||
View actionBarTitleView = window.getDecorView().findViewById(actionBarTitleId);
|
||||
if (actionBarTitleView != null) { // it's null in Android 2.x
|
||||
getWindow().getDecorView().findViewById(actionBarTitleId).
|
||||
window.getDecorView().findViewById(actionBarTitleId).
|
||||
setContentDescription(getString(R.string.actionbar_settings));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import android.support.v4.app.DialogFragment;
|
|||
import android.support.v7.app.AlertDialog;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager.LayoutParams;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
@ -106,8 +107,9 @@ public class CreateFolderDialogFragment
|
|||
accentColor));
|
||||
Dialog d = builder.create();
|
||||
|
||||
if (d.getWindow() != null) {
|
||||
d.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
||||
Window window = d.getWindow();
|
||||
if (window != null) {
|
||||
window.setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
||||
}
|
||||
|
||||
return d;
|
||||
|
|
|
@ -26,6 +26,7 @@ import android.support.v4.app.DialogFragment;
|
|||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.app.AlertDialog.Builder;
|
||||
import android.text.InputType;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager.LayoutParams;
|
||||
import android.webkit.HttpAuthHandler;
|
||||
import android.webkit.WebView;
|
||||
|
@ -105,8 +106,9 @@ public class CredentialsDialogFragment extends DialogFragment
|
|||
|
||||
Dialog d = authDialog.create();
|
||||
|
||||
if (d.getWindow() != null) {
|
||||
d.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
||||
Window window = d.getWindow();
|
||||
if (window != null) {
|
||||
window.setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
||||
}
|
||||
|
||||
return d;
|
||||
|
|
|
@ -35,6 +35,7 @@ import android.support.v4.app.DialogFragment;
|
|||
import android.support.v7.app.AlertDialog;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager.LayoutParams;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
@ -120,8 +121,9 @@ public class RenameFileDialogFragment
|
|||
accentColor));
|
||||
Dialog d = builder.create();
|
||||
|
||||
if (d.getWindow() != null) {
|
||||
d.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
||||
Window window = d.getWindow();
|
||||
if (window != null) {
|
||||
window.setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
||||
}
|
||||
|
||||
return d;
|
||||
|
|
|
@ -32,6 +32,7 @@ import android.support.v7.app.AlertDialog;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
@ -119,8 +120,9 @@ public class SharePasswordDialogFragment extends DialogFragment implements Dialo
|
|||
.setTitle(R.string.share_link_password_title);
|
||||
Dialog d = builder.create();
|
||||
|
||||
if (d.getWindow() != null) {
|
||||
d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
||||
Window window = d.getWindow();
|
||||
if (window != null) {
|
||||
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
||||
}
|
||||
|
||||
return d;
|
||||
|
|
|
@ -46,6 +46,7 @@ import android.support.v7.widget.AppCompatCheckBox;
|
|||
import android.support.v7.widget.SwitchCompat;
|
||||
import android.text.Html;
|
||||
import android.text.Spanned;
|
||||
import android.view.Window;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.SeekBar;
|
||||
|
@ -314,8 +315,9 @@ public class ThemeUtils {
|
|||
* @param color the color
|
||||
*/
|
||||
public static void colorStatusBar(FragmentActivity fragmentActivity, @ColorInt int color) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && fragmentActivity.getWindow() != null) {
|
||||
fragmentActivity.getWindow().setStatusBarColor(color);
|
||||
Window window = fragmentActivity.getWindow();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && window != null) {
|
||||
window.setStatusBarColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue