Use matching status bar color during action mode

Closes #3552
FREEBIE.
This commit is contained in:
Veeti Paananen 2015-07-08 00:46:21 +03:00 committed by Moxie Marlinspike
parent d6d881b0ca
commit 21c8051b02
3 changed files with 31 additions and 0 deletions

View File

@ -32,6 +32,7 @@
<color name="textsecure_holo_blue_light">#ff33b5e5</color>
<color name="dark_action_bar">#ff111111</color>
<color name="action_mode_status_bar">#ff1f1f1f</color>
<color name="touch_highlight">#400099cc</color>
<color name="light_button">#33ffffff</color>
<color name="light_button_highlight">#66ffffff</color>

View File

@ -6,6 +6,7 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.support.v4.app.LoaderManager;
@ -21,6 +22,7 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;
@ -345,11 +347,19 @@ public class ConversationFragment extends ListFragment
private class ActionModeCallback implements ActionMode.Callback {
private int statusBarColor;
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
MenuInflater inflater = mode.getMenuInflater();
inflater.inflate(R.menu.conversation_context, menu);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = getActivity().getWindow();
statusBarColor = window.getStatusBarColor();
window.setStatusBarColor(getResources().getColor(R.color.action_mode_status_bar));
}
setCorrectMenuVisibility(menu);
return true;
}
@ -364,6 +374,10 @@ public class ConversationFragment extends ListFragment
((ConversationAdapter)getListAdapter()).getBatchSelected().clear();
((ConversationAdapter)getListAdapter()).notifyDataSetChanged();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getActivity().getWindow().setStatusBarColor(statusBarColor);
}
actionMode = null;
}

View File

@ -19,8 +19,11 @@ package org.thoughtcrime.securesms;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.TypedArray;
import android.database.Cursor;
import android.graphics.Color;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.LoaderManager;
@ -267,6 +270,11 @@ public class ConversationListFragment extends Fragment
mode.setTitle(R.string.conversation_fragment_cab__batch_selection_mode);
mode.setSubtitle(null);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getActivity().getWindow()
.setStatusBarColor(getResources().getColor(R.color.action_mode_status_bar));
}
return true;
}
@ -288,6 +296,14 @@ public class ConversationListFragment extends Fragment
@Override
public void onDestroyActionMode(ActionMode mode) {
getListAdapter().initializeBatchMode(false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
TypedArray color = getActivity().getTheme()
.obtainStyledAttributes(new int[] { android.R.attr.statusBarColor });
getActivity().getWindow().setStatusBarColor(color.getColor(0, Color.BLACK));
color.recycle();
}
actionMode = null;
}