List of usage examples for android.view Window setStatusBarColor
public abstract void setStatusBarColor(@ColorInt int color);
From source file:com.granita.tasks.TaskListActivity.java
@SuppressLint("NewApi") @Override/* w w w . j av a2 s. co m*/ public void updateColor(int color) { getSupportActionBar().setBackgroundDrawable(new ColorDrawable(color)); mTabs.setBackgroundColor(color); if (VERSION.SDK_INT >= 21) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(color); } }
From source file:com.eugene.fithealthmaingit.UI.ChooseAddMealTabsFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { v = inflater.inflate(R.layout.fragment_search_add_item_pager, container, false); // Change the status bar color if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window w = getActivity().getWindow(); w.setStatusBarColor(getResources().getColor(R.color.accent_dark)); }//from w ww.j ava 2s .c o m Bundle extras = getActivity().getIntent().getExtras(); if (extras != null) { mealType = extras.getString(Globals.MEAL_TYPE); page = extras.getInt("PAGE"); } card_search_manual = (CardView) v.findViewById(R.id.card_search_manual); card_search_fav = (CardView) v.findViewById(R.id.card_search_fav); // Initiate Toolbar Toolbar mToolbar = (Toolbar) v.findViewById(R.id.toolbar_search_main); ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(mToolbar.getWindowToken(), 0); mToolbar.setNavigationIcon(R.mipmap.ic_arrow_back); mToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getActivity().finish(); } }); mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { if (menuItem.getItemId() == R.id.action_search) mCallbacks.searchClicked(); if (menuItem.getItemId() == R.id.action_manual) { Intent i = new Intent(getActivity(), ManualEntryActivity.class); i.putExtra(Globals.MEAL_TYPE, mealType); startActivity(i); } return false; } }); TextViewFont txtTitle = (TextViewFont) v.findViewById(R.id.txtTitle); if (txtTitle != null) txtTitle.setText(mealType); mToolbar.inflateMenu(R.menu.menu_search_add); // Hide keyboard ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(mToolbar.getWindowToken(), 0); // Initiate Pager and Tabs ChooseAddMealPagerAdapter myPagerAdapterAdd = new ChooseAddMealPagerAdapter(); ViewPager mViewPager = (ViewPager) v.findViewById(R.id.pager); TabLayout tabs = (TabLayout) v.findViewById(R.id.tabs); tabs.setTabTextColors(Color.parseColor("#80ffffff"), Color.parseColor("#ffffff")); tabs.setTabMode(TabLayout.MODE_SCROLLABLE); mViewPager.setAdapter(myPagerAdapterAdd); mViewPager.setOffscreenPageLimit(4); tabs.setupWithViewPager(mViewPager); mViewPager.setCurrentItem(page); // Initiate ListView and their adapters ListView mListRecentSearches = (ListView) v.findViewById(R.id.listRecentSearches); mListFavorites = (ListView) v.findViewById(R.id.listFavorites); listViewManual = (ListView) v.findViewById(R.id.listViewManual); llNoRecentFav = (LinearLayout) v.findViewById(R.id.llNoRecentFav); llNoRecentManual = (LinearLayout) v.findViewById(R.id.llNoRecentManual); llNoRecentSearch = (LinearLayout) v.findViewById(R.id.llNoRecentSearch); mRecentLogAdapter = new LogQuickSearchSimpleAdapter(getActivity(), 0, LogQuickSearch.all()); mListRecentSearches.setAdapter(mRecentLogAdapter); mListRecentSearches.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { LogQuickSearch recentLog = mRecentLogAdapter.getItem(position); mCallbacks.recentSearchClicked(recentLog.getName()); } }); mLogAdapterFavorite = new LogAdapterAll(getActivity(), 0, LogMeal.logSortByFavorite("favorite")); ViewGroup headerFav = (ViewGroup) inflater.inflate(R.layout.list_header_search_favorites, listViewManual, false); mListFavorites.addHeaderView(headerFav, null, false); mListFavorites.setAdapter(mLogAdapterFavorite); mListFavorites.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(searchManual.getWindowToken(), 0); LogMeal logMeal = mLogAdapterFavorite.getItem(position - 1); Intent i = new Intent(getActivity(), SaveSearchAddItemActivityMain.class); i.putExtra(Globals.MEAL_TYPE, mealType); i.putExtra(Globals.MEAL_ID, logMeal.getMealId()); i.putExtra(Globals.MEAL_BRAND, logMeal.getBrand()); i.putExtra(Globals.MEAL_FAVORITE, logMeal.getFavorite()); startActivity(i); } }); mLogAdapterManual = new LogAdapterManual(getActivity(), 0, LogManual.all(), mealType); ViewGroup header = (ViewGroup) inflater.inflate(R.layout.list_header_search, listViewManual, false); listViewManual.addHeaderView(header, null, false); listViewManual.setAdapter(mLogAdapterManual); listViewManual.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(searchManual.getWindowToken(), 0); LogManual logManual = mLogAdapterManual.getItem(position - 1); Intent i = new Intent(getActivity(), ManualEntrySaveMealActivity.class); i.putExtra(Globals.MEAL_TYPE, mealType); i.putExtra(Globals.MEAL_ID, logManual.getMealId()); startActivity(i); } }); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { ((RelativeLayout.LayoutParams) card_search_manual.getLayoutParams()).setMargins(0, 0, 0, 0); // get rid of margins since shadow area is now the margin ((RelativeLayout.LayoutParams) card_search_fav.getLayoutParams()).setMargins(0, 0, 0, 0); // get rid of margins since shadow area is now the margin headerFav.setPadding(0, 0, 0, Equations.dpToPx(getActivity(), 16)); header.setPadding(0, 0, 0, Equations.dpToPx(getActivity(), 16)); } searchManualEntry(); searchFav(); /** * TODO RECIPE */ Button btnRecipe = (Button) v.findViewById(R.id.btnRecipe); btnRecipe.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { LogRecipeHolder newRecipe = new LogRecipeHolder(); newRecipe.setDate(new Date()); newRecipe.setMealChoice(mealType); newRecipe.setMealName("Recipe"); newRecipe.save(); Intent i = new Intent(getActivity(), RecipeActivity.class); i.putExtra(Globals.MEAL_ID, newRecipe.getId()); i.putExtra(Globals.MEAL_TYPE, mealType); startActivity(i); } }); logAdapterMealRecipe = new LogRecipeHolderAdapter(getActivity(), 0, LogRecipeHolder.all()); listRecipes = (ListView) v.findViewById(R.id.listRecipes); listRecipes.setAdapter(logAdapterMealRecipe); listRecipes.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { LogRecipeHolder newRecipe = logAdapterMealRecipe.getItem(position); Intent i = new Intent(getActivity(), RecipeActivity.class); i.putExtra(Globals.MEAL_ID, newRecipe.getId()); i.putExtra(Globals.MEAL_TYPE, mealType); startActivity(i); } }); searchManual = (Button) v.findViewById(R.id.searchManual); searchManual.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { handleSearchManual(); } }); searchFavorite = (Button) v.findViewById(R.id.searchFav); searchFavorite.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { handleSearchFavorite(); } }); updateListView(); mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(searchManual.getWindowToken(), 0); } @Override public void onPageSelected(int position) { } @Override public void onPageScrollStateChanged(int state) { } }); return v; }
From source file:org.docrj.smartcard.reader.GroupViewActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_group_view); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/*from ww w. j av a 2s .c o m*/ toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onBackPressed(); } }); mNote = (TextView) findViewById(R.id.note); mGrpListView = (AnimatedExpandableListView) findViewById(R.id.listView); // custom click handler so we can ignore and not collapse mGrpListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() { @Override public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { return true; } }); mGrpListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { SmartcardApp app = mGrpAdapter.getChild(groupPosition, childPosition); // view app Intent i = new Intent(GroupViewActivity.this, AppViewActivity.class); i.setAction(ACTION_VIEW_APP); i.putExtra(EXTRA_APP_POS, mApps.indexOf(app)); startActivity(i); return true; } }); // persistent data in shared prefs SharedPreferences ss = getSharedPreferences("prefs", Context.MODE_PRIVATE); mEditor = ss.edit(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window w = getWindow(); w.setFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); w.setStatusBarColor(getResources().getColor(R.color.primary_dark)); } }
From source file:com.filemanager.free.activities.TextReader.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Sp = PreferenceManager.getDefaultSharedPreferences(this); if (theme1 == 1) { getWindow().getDecorView().setBackgroundColor(ContextCompat.getColor(c, R.color.holo_dark_background)); }/*www. j ava2 s .c o m*/ setContentView(R.layout.search); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); skin = PreferenceUtils.getPrimaryColorString(Sp); findViewById(R.id.lin).setBackgroundColor(Color.parseColor(skin)); if (Build.VERSION.SDK_INT >= 21) { ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("File Manager", ((BitmapDrawable) ContextCompat.getDrawable(c, R.mipmap.ic_launcher)).getBitmap(), Color.parseColor(skin)); ((Activity) this).setTaskDescription(taskDescription); } int skinStatusBar = PreferenceUtils.getStatusColor(skin); assert (getSupportActionBar()) != null; getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin))); getSupportActionBar().setDisplayHomeAsUpEnabled(true); if (Build.VERSION.SDK_INT == 20 || Build.VERSION.SDK_INT == 19) { SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setStatusBarTintColor(Color.parseColor(skin)); FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.texteditor) .getLayoutParams(); SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); p.setMargins(0, config.getStatusBarHeight(), 0, 0); } else if (Build.VERSION.SDK_INT >= 21) { boolean colourednavigation = Sp.getBoolean("colorednavigation", true); Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.setStatusBarColor((PreferenceUtils.getStatusColor(skin))); if (colourednavigation) window.setNavigationBarColor((PreferenceUtils.getStatusColor(skin))); } mInput = (EditText) findViewById(R.id.fname); scrollView = (ScrollView) findViewById(R.id.editscroll); try { if (getIntent().getData() != null) { uri = getIntent().getData(); mFile = new File(getIntent().getData().getPath()); } else mFile = new File(getIntent().getStringExtra("path")); } catch (Exception e) { mFile = null; } String fileName = null; try { if (uri.getScheme().equals("file")) { fileName = uri.getLastPathSegment(); } else { Cursor cursor = null; try { cursor = getContentResolver().query(uri, new String[] { MediaStore.Images.ImageColumns.DISPLAY_NAME }, null, null, null); if (cursor != null && cursor.moveToFirst()) { fileName = cursor .getString(cursor.getColumnIndex(MediaStore.Images.ImageColumns.DISPLAY_NAME)); } } finally { if (cursor != null) { cursor.close(); } } } } catch (Exception e) { e.printStackTrace(); } if (fileName == null || fileName.trim().length() == 0) fileName = f.getName(); getSupportActionBar().setTitle(fileName); mInput.addTextChangedListener(this); try { if (theme1 == 1) mInput.setBackgroundColor(ContextCompat.getColor(c, R.color.holo_dark_background)); getSupportActionBar().setDisplayHomeAsUpEnabled(true); } catch (Exception ignored) { } if (savedInstanceState != null) { mOriginal = savedInstanceState.getString(KEY_ORIGINAL_TEXT); int index = savedInstanceState.getInt(KEY_INDEX); mInput.setText(savedInstanceState.getString(KEY_MODIFIED_TEXT)); mInput.setScrollY(index); } else { load(mFile); } }
From source file:com.ijiaban.yinxiang.MainActivity.java
/** * Changes the color of the action bar and status bar * @param color ARGB Color to apply/* w w w . j a va 2 s . c o m*/ */ @SuppressLint("NewApi") private void setColor(int color) { View mainView = findViewById(R.id.rootView); if (mainView == null) { Log.e("MainActivity:setColor()", "WARNING: Did not find root view."); } else { mainView.setBackgroundColor(color); } /* Set the action bar colour to the average colour of the generated image and the status bar colour for Android Version >= 5.0 accordingly. */ try { getSupportActionBar().setBackgroundDrawable(new ColorDrawable(color)); } catch (NullPointerException nullError) { Log.e("MainActivity:generateImageTask()", nullError.toString()); } catch (NoSuchMethodError methodError) { Log.e("MainActivity:generateImageTask()", methodError.toString()); } Log.d("MainActivity:generateImageTask()", "Changing status bar & action bar colour."); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // Get the window through a reference to the activity. Activity parent = (Activity) mContext; Window window = parent.getWindow(); // Set the status bar colour of this window. int statusColor = ColorUtilities.getDarkenedColor(color); window.setStatusBarColor(statusColor); } }
From source file:com.breadwallet.presenter.activities.MainActivity.java
private void setStatusBarColor() { Window window = getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(getColor(R.color.status_bar)); }
From source file:com.ferid.app.classroom.statistics.StatisticalListActivity.java
/** * Set status bar colour on graph visibility change *///from w w w . j a v a 2s. c o m private void setStatusBarColour() { if (Build.VERSION.SDK_INT >= 21) { Window window = getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); if (graphLayout.getVisibility() == View.VISIBLE) { Configuration configuration = getResources().getConfiguration(); if (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) { window.setStatusBarColor(ContextCompat.getColor(this, R.color.materialLightGreen)); } else if (configuration.orientation == Configuration.ORIENTATION_PORTRAIT) { window.setStatusBarColor(ContextCompat.getColor(this, R.color.colourPrimaryDark)); } } else { window.setStatusBarColor(ContextCompat.getColor(this, R.color.colourPrimaryDark)); } } }
From source file:com.hellofyc.base.app.activity.BaseActivity.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public void setStatusBarColorTransparent() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(Color.TRANSPARENT); window.setNavigationBarColor(Color.TRANSPARENT); }// ww w .j av a2 s . co m }
From source file:de.uni_koblenz_landau.apow.LoginActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Re-attach Tasks. TaskActivityReference.getInstance().attach(LoginTask.TASK_ID, this); TaskActivityReference.getInstance().attach(SetupTask.TASK_ID, this); TaskActivityReference.getInstance().attach(NFCTagReaderTask.TASK_ID, this); TaskActivityReference.getInstance().attach(LocationWebTask.TASK_ID, this); // Create UI references. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = this.getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.setStatusBarColor(this.getResources().getColor(R.color.color_primary_dark)); }//from w w w. j a v a 2 s .c o m setContentView(R.layout.login_activity); mToolbar = (Toolbar) findViewById(R.id.toolbar); if (mToolbar != null) { setSupportActionBar(mToolbar); } mSetupLocationView = (Spinner) findViewById(R.id.login_setup_locations); mStatusView = findViewById(R.id.login_status); mStatusMessageView = (TextView) findViewById(R.id.login_status_message); mLoginFormView = findViewById(R.id.login_login); mLoginPasswordView = (EditText) findViewById(R.id.login_login_password); mLoginPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) { if (id == R.id.login || id == EditorInfo.IME_NULL) { login(textView); return true; } return false; } }); mLoginNFCText = (TextView) findViewById(R.id.login_login_nfc); mSetupFormView = findViewById(R.id.login_setup); mSetupNFCText = (TextView) findViewById(R.id.login_setup_nfc); mSetupDatabasePasswordView = (EditText) findViewById(R.id.login_setup_database_password); mSetupDatabaseConfirmView = (EditText) findViewById(R.id.login_setup_database_password_confirm); mSetupServerUsernameView = (EditText) findViewById(R.id.login_login_server_user); mSetupServerPasswordView = (EditText) findViewById(R.id.login_login_server_password); //mFirstRun = true; mFirstRun = getSharedPreferences(Constants.PREFERENCE, MODE_PRIVATE).getBoolean(ARG_FIRST_RUN, true); mNfcAdapter = NfcAdapter.getDefaultAdapter(this); // Restore UI from saved instance or load data. if (savedInstanceState != null) { mNFCTag = savedInstanceState.getString(ARG_NFC); mNFCTextDrawable = savedInstanceState.getInt(ARG_NFC_STATE); mAutoSignOffDismissed = savedInstanceState.getBoolean(ARG_AUTO_SIGN_OFF_DISMISSED); mProgress = savedInstanceState.getBoolean(ARG_PROGRESS); if (mFirstRun) { mLocations = savedInstanceState.getParcelableArrayList(ARG_LOCATIONS); if (mLocations != null) { ArrayAdapter<ListViewItem> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, mLocations); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mSetupLocationView.setAdapter(adapter); mSetupLocationView.setSelection(savedInstanceState.getInt(ARG_LOCATION_SELECTION)); } } } else { mProgress = false; mAutoSignOffDismissed = false; mNFCTag = ""; mNFCTextDrawable = R.drawable.empty; if (mFirstRun) { loadLocations(); } } mLoginNFCText.setCompoundDrawablesWithIntrinsicBounds(0, 0, mNFCTextDrawable, 0); mSetupNFCText.setCompoundDrawablesWithIntrinsicBounds(0, 0, mNFCTextDrawable, 0); if (mFirstRun) { mSetupFormView.setVisibility(View.VISIBLE); mLoginFormView.setVisibility(View.GONE); this.setTitle(R.string.login_setup_title); } else { mSetupFormView.setVisibility(View.GONE); mLoginFormView.setVisibility(View.VISIBLE); this.setTitle(R.string.login_login_title); } if (getIntent().getBooleanExtra(ARG_AUTO_LOGOUT, false) && !mAutoSignOffDismissed) { SignedOffDialog dialog = new SignedOffDialog(); dialog.show(getSupportFragmentManager(), SIGNED_OFF_DIALOG_ID); mAutoSignOffDismissed = true; } showProgress(mProgress); setNFCState(); }
From source file:com.nbplus.vbroadlauncher.RadioActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (Constants.OPEN_BETA_PHONE && LauncherSettings.getInstance(this).isSmartPhone()) { this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); }//from ww w .java 2s .co m mSettingsContentObserver = new SettingsContentObserver(this, new Handler()); getApplicationContext().getContentResolver().registerContentObserver( android.provider.Settings.System.CONTENT_URI, true, mSettingsContentObserver); showProgressDialog(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.setStatusBarColor(getResources().getColor(R.color.activity_radio_background)); } overridePendingTransition(R.anim.fade_in, R.anim.fade_out); setContentView(R.layout.activity_radio); Intent i = getIntent(); mShortcutData = i.getParcelableExtra(Constants.EXTRA_NAME_SHORTCUT_DATA); if (mShortcutData == null) { Log.e(TAG, "mShortcutData is not found.."); finishActivity(); return; } IntentFilter filter = new IntentFilter(); filter.addAction(MusicService.ACTION_PLAYED); filter.addAction(MusicService.ACTION_PAUSED); filter.addAction(MusicService.ACTION_STOPPED); filter.addAction(MusicService.ACTION_COMPLETED); filter.addAction(MusicService.ACTION_ERROR); filter.addAction(MusicService.ACTION_PLAYING_STATUS); LocalBroadcastManager.getInstance(this).registerReceiver(mBroadcastReceiver, filter); // send playing status Intent queryStatus = new Intent(this, MusicService.class); queryStatus.setAction(MusicService.ACTION_PLAYING_STATUS); startService(queryStatus); // ViewPager . // ??? ? ? ? . mViewPager = (NbplusViewPager) findViewById(R.id.viewPager); mIndicator = (CirclePageIndicator) findViewById(R.id.indicator); // close button ImageButton closeButton = (ImageButton) findViewById(R.id.btn_close); closeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finishActivity(); } }); mActivityLayout = (RelativeLayout) findViewById(R.id.radio_activity_background); int wallpaperId = LauncherSettings.getInstance(this).getWallpaperId(); mActivityLayout.setBackgroundResource(LauncherSettings.landWallpaperResource[wallpaperId]); // title. mRadioTitle = (TextView) findViewById(R.id.radio_activity_label); // media controller mPlayToggle = (ImageButton) findViewById(R.id.ic_media_control_play); mPlayToggle.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mCurrentPlayingStatus == null) { return; } MusicService.State state = (MusicService.State) mCurrentPlayingStatus .getSerializable(MusicService.EXTRA_PLAYING_STATUS); Intent i = new Intent(RadioActivity.this, MusicService.class); if (state == MusicService.State.Playing) { i.setAction(MusicService.ACTION_PAUSE); } else if (state == MusicService.State.Paused) { i.setAction(MusicService.ACTION_PLAY); } startService(i); } }); mPlayStop = (ImageButton) findViewById(R.id.ic_media_control_stop); mPlayStop.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mCurrentPlayingStatus == null) { return; } MusicService.State state = (MusicService.State) mCurrentPlayingStatus .getSerializable(MusicService.EXTRA_PLAYING_STATUS); if (state == MusicService.State.Playing || state == MusicService.State.Paused) { Intent i = new Intent(RadioActivity.this, MusicService.class); i.setAction(MusicService.ACTION_STOP); i.putExtra(MusicService.EXTRA_MUSIC_FORCE_STOP, false); startService(i); } } }); mSoundToggle = (ImageButton) findViewById(R.id.ic_media_control_volume_btn); AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE); int currentVolume = audio.getStreamVolume(AudioManager.STREAM_MUSIC); int maxVolume = audio.getStreamMaxVolume(AudioManager.STREAM_MUSIC); if (currentVolume <= 0) { mSoundToggle.setBackgroundResource(R.drawable.ic_button_radio_sound_off); } else { mSoundToggle.setBackgroundResource(R.drawable.ic_button_radio_sound_on); } mSoundToggle.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE); if (audio.getStreamVolume(AudioManager.STREAM_MUSIC) <= 0) { if (mSoundTogglePreviousValue > 0) { audio.setStreamVolume(AudioManager.STREAM_MUSIC, mSoundTogglePreviousValue, AudioManager.FLAG_PLAY_SOUND); } else { mSoundTogglePreviousValue = 1; audio.setStreamVolume(AudioManager.STREAM_MUSIC, mSoundTogglePreviousValue, AudioManager.FLAG_PLAY_SOUND); } mSoundToggle.setBackgroundResource(R.drawable.ic_button_radio_sound_on); mSeekbar.setProgress(mSoundTogglePreviousValue); mSoundTogglePreviousValue = -1; } else { mSoundTogglePreviousValue = audio.getStreamVolume(AudioManager.STREAM_MUSIC); audio.setStreamVolume(AudioManager.STREAM_MUSIC, 0, AudioManager.FLAG_PLAY_SOUND); mSoundToggle.setBackgroundResource(R.drawable.ic_button_radio_sound_off); } } }); mSeekbar = (SeekBar) findViewById(R.id.ic_media_control_volume_seek); mSeekbar.setMax(maxVolume); mSeekbar.setProgress(currentVolume); mSeekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser) { mSoundTogglePreviousValue = -1; AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE); audio.setStreamVolume(AudioManager.STREAM_MUSIC, progress, AudioManager.FLAG_PLAY_SOUND); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); getRadioChannelTask = new GetRadioChannelTask(); if (getRadioChannelTask != null) { getRadioChannelTask.setBroadcastApiData(this, mHandler, mShortcutData.getDomain() + mShortcutData.getPath()); mIsExecuteGetRadioChannelTask = true; getRadioChannelTask.execute(); } }