List of usage examples for android.view ContextThemeWrapper ContextThemeWrapper
public ContextThemeWrapper(Context base, Resources.Theme theme)
From source file:io.flutter.plugins.localauth.AuthenticationHelper.java
@SuppressLint("InflateParams") private void showGoToSettingsDialog() { View view = LayoutInflater.from(activity).inflate(R.layout.go_to_setting, null, false); TextView message = (TextView) view.findViewById(R.id.fingerprint_required); TextView description = (TextView) view.findViewById(R.id.go_to_setting_description); message.setText((String) call.argument("fingerprintRequired")); description.setText((String) call.argument("goToSettingDescription")); Context context = new ContextThemeWrapper(activity, R.style.AlertDialogCustom); OnClickListener goToSettingHandler = new OnClickListener() { @Override//from ww w .j ava 2 s. c om public void onClick(DialogInterface dialog, int which) { stop(false); activity.startActivity(new Intent(Settings.ACTION_SECURITY_SETTINGS)); } }; OnClickListener cancelHandler = new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { stop(false); } }; new AlertDialog.Builder(context).setView(view) .setPositiveButton((String) call.argument("goToSetting"), goToSettingHandler) .setNegativeButton((String) call.argument(CANCEL_BUTTON), cancelHandler).setCancelable(false) .show(); }
From source file:com.farmerbb.taskbar.service.StartMenuService.java
@SuppressLint("RtlHardcoded") private void drawStartMenu() { IconCache.getInstance(this).clearCache(); final SharedPreferences pref = U.getSharedPreferences(this); final boolean hasHardwareKeyboard = getResources() .getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS; switch (pref.getString("show_search_bar", "keyboard")) { case "always": shouldShowSearchBox = true;//from w w w . ja va 2 s .c om break; case "keyboard": shouldShowSearchBox = hasHardwareKeyboard; break; case "never": shouldShowSearchBox = false; break; } // Initialize layout params windowManager = (WindowManager) getSystemService(WINDOW_SERVICE); U.setCachedRotation(windowManager.getDefaultDisplay().getRotation()); final WindowManager.LayoutParams params = new WindowManager.LayoutParams( WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_PHONE, shouldShowSearchBox ? 0 : WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, PixelFormat.TRANSLUCENT); // Determine where to show the start menu on screen switch (U.getTaskbarPosition(this)) { case "bottom_left": layoutId = R.layout.start_menu_left; params.gravity = Gravity.BOTTOM | Gravity.LEFT; break; case "bottom_vertical_left": layoutId = R.layout.start_menu_vertical_left; params.gravity = Gravity.BOTTOM | Gravity.LEFT; break; case "bottom_right": layoutId = R.layout.start_menu_right; params.gravity = Gravity.BOTTOM | Gravity.RIGHT; break; case "bottom_vertical_right": layoutId = R.layout.start_menu_vertical_right; params.gravity = Gravity.BOTTOM | Gravity.RIGHT; break; case "top_left": layoutId = R.layout.start_menu_top_left; params.gravity = Gravity.TOP | Gravity.LEFT; break; case "top_vertical_left": layoutId = R.layout.start_menu_vertical_left; params.gravity = Gravity.TOP | Gravity.LEFT; break; case "top_right": layoutId = R.layout.start_menu_top_right; params.gravity = Gravity.TOP | Gravity.RIGHT; break; case "top_vertical_right": layoutId = R.layout.start_menu_vertical_right; params.gravity = Gravity.TOP | Gravity.RIGHT; break; } // Initialize views int theme = 0; switch (pref.getString("theme", "light")) { case "light": theme = R.style.AppTheme; break; case "dark": theme = R.style.AppTheme_Dark; break; } ContextThemeWrapper wrapper = new ContextThemeWrapper(this, theme); layout = (StartMenuLayout) LayoutInflater.from(wrapper).inflate(layoutId, null); startMenu = (GridView) layout.findViewById(R.id.start_menu); if ((shouldShowSearchBox && !hasHardwareKeyboard) || Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) layout.viewHandlesBackButton(); boolean scrollbar = pref.getBoolean("scrollbar", false); startMenu.setFastScrollEnabled(scrollbar); startMenu.setFastScrollAlwaysVisible(scrollbar); startMenu.setScrollBarStyle(scrollbar ? View.SCROLLBARS_OUTSIDE_INSET : View.SCROLLBARS_INSIDE_OVERLAY); if (pref.getBoolean("transparent_start_menu", false)) startMenu.setBackgroundColor(0); searchView = (SearchView) layout.findViewById(R.id.search); int backgroundTint = U.getBackgroundTint(this); FrameLayout startMenuFrame = (FrameLayout) layout.findViewById(R.id.start_menu_frame); FrameLayout searchViewLayout = (FrameLayout) layout.findViewById(R.id.search_view_layout); startMenuFrame.setBackgroundColor(backgroundTint); searchViewLayout.setBackgroundColor(backgroundTint); if (shouldShowSearchBox) { if (!hasHardwareKeyboard) searchView.setIconifiedByDefault(true); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { if (!hasSubmittedQuery) { ListAdapter adapter = startMenu.getAdapter(); if (adapter != null) { hasSubmittedQuery = true; if (adapter.getCount() > 0) { View view = adapter.getView(0, null, startMenu); LinearLayout layout = (LinearLayout) view.findViewById(R.id.entry); layout.performClick(); } else { if (pref.getBoolean("hide_taskbar", true) && !FreeformHackHelper.getInstance().isInFreeformWorkspace()) LocalBroadcastManager.getInstance(StartMenuService.this) .sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_TASKBAR")); else LocalBroadcastManager.getInstance(StartMenuService.this) .sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_START_MENU")); Intent intent = new Intent(Intent.ACTION_WEB_SEARCH); intent.putExtra(SearchManager.QUERY, query); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (intent.resolveActivity(getPackageManager()) != null) startActivity(intent); else { Uri uri = new Uri.Builder().scheme("https").authority("www.google.com") .path("search").appendQueryParameter("q", query).build(); intent = new Intent(Intent.ACTION_VIEW); intent.setData(uri); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try { startActivity(intent); } catch (ActivityNotFoundException e) { /* Gracefully fail */ } } } } } return true; } @Override public boolean onQueryTextChange(String newText) { searchView.setIconified(false); View closeButton = searchView.findViewById(R.id.search_close_btn); if (closeButton != null) closeButton.setVisibility(View.GONE); refreshApps(newText, false); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) { new Handler().postDelayed(() -> { EditText editText = (EditText) searchView.findViewById(R.id.search_src_text); if (editText != null) { editText.requestFocus(); editText.setSelection(editText.getText().length()); } }, 50); } return true; } }); searchView.setOnQueryTextFocusChangeListener((view, b) -> { if (!hasHardwareKeyboard) { ViewGroup.LayoutParams params1 = startMenu.getLayoutParams(); params1.height = getResources().getDimensionPixelSize(b && !U.isServiceRunning(this, "com.farmerbb.secondscreen.service.DisableKeyboardService") ? R.dimen.start_menu_height_half : R.dimen.start_menu_height); startMenu.setLayoutParams(params1); } if (!b) { if (hasHardwareKeyboard && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) LocalBroadcastManager.getInstance(StartMenuService.this) .sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_START_MENU")); else { InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); } } }); searchView.setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI); LinearLayout powerButton = (LinearLayout) layout.findViewById(R.id.power_button); powerButton.setOnClickListener(view -> { int[] location = new int[2]; view.getLocationOnScreen(location); openContextMenu(location); }); powerButton.setOnGenericMotionListener((view, motionEvent) -> { if (motionEvent.getAction() == MotionEvent.ACTION_BUTTON_PRESS && motionEvent.getButtonState() == MotionEvent.BUTTON_SECONDARY) { int[] location = new int[2]; view.getLocationOnScreen(location); openContextMenu(location); } return false; }); searchViewLayout.setOnClickListener(view -> searchView.setIconified(false)); startMenu.setOnItemClickListener((parent, view, position, id) -> { hideStartMenu(); AppEntry entry = (AppEntry) parent.getAdapter().getItem(position); U.launchApp(StartMenuService.this, entry.getPackageName(), entry.getComponentName(), entry.getUserId(StartMenuService.this), null, false, false); }); if (pref.getBoolean("transparent_start_menu", false)) layout.findViewById(R.id.search_view_child_layout).setBackgroundColor(0); } else searchViewLayout.setVisibility(View.GONE); textView = (TextView) layout.findViewById(R.id.no_apps_found); LocalBroadcastManager.getInstance(this).unregisterReceiver(toggleReceiver); LocalBroadcastManager.getInstance(this).unregisterReceiver(toggleReceiverAlt); LocalBroadcastManager.getInstance(this).unregisterReceiver(hideReceiver); LocalBroadcastManager.getInstance(this).registerReceiver(toggleReceiver, new IntentFilter("com.farmerbb.taskbar.TOGGLE_START_MENU")); LocalBroadcastManager.getInstance(this).registerReceiver(toggleReceiverAlt, new IntentFilter("com.farmerbb.taskbar.TOGGLE_START_MENU_ALT")); LocalBroadcastManager.getInstance(this).registerReceiver(hideReceiver, new IntentFilter("com.farmerbb.taskbar.HIDE_START_MENU")); handler = new Handler(); refreshApps(true); windowManager.addView(layout, params); }
From source file:org.fdroid.fdroid.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_login: if (mService != null) { com.skubit.Utils.startAuthorization(this, mService); } else {/*from w w w .j a v a 2 s . c o m*/ if (!com.skubit.Utils.isIabInstalled(getPackageManager())) { startActivityForResult(com.skubit.Utils.getIabIntent(), com.skubit.Utils.PLAY_CODE); } } return true; case R.id.action_update_repo: updateRepos(); return true; case R.id.action_manage_repos: Intent i = new Intent(this, ManageReposActivity.class); startActivityForResult(i, REQUEST_MANAGEREPOS); return true; case R.id.action_settings: Intent prefs = new Intent(getBaseContext(), PreferencesActivity.class); startActivityForResult(prefs, REQUEST_PREFS); return true; case R.id.action_swap: startActivity(new Intent(this, SwapActivity.class)); return true; case R.id.action_search: onSearchRequested(); return true; case R.id.action_bluetooth_apk: /* * If Bluetooth has not been enabled/turned on, then enabling * device discoverability will automatically enable Bluetooth */ Intent discoverBt = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE); discoverBt.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 121); startActivityForResult(discoverBt, REQUEST_ENABLE_BLUETOOTH); // if this is successful, the Bluetooth transfer is started return true; case R.id.action_about: View view = null; if (Build.VERSION.SDK_INT >= 11) { LayoutInflater li = LayoutInflater.from(this); view = li.inflate(R.layout.about, null); } else { view = View.inflate(new ContextThemeWrapper(this, R.style.AboutDialogLight), R.layout.about, null); } // Fill in the version... try { PackageInfo pi = getPackageManager().getPackageInfo(getApplicationContext().getPackageName(), 0); ((TextView) view.findViewById(R.id.version)).setText(pi.versionName); } catch (Exception e) { } AlertDialog.Builder p = null; if (Build.VERSION.SDK_INT >= 11) { p = new AlertDialog.Builder(this).setView(view); } else { p = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.AboutDialogLight)).setView(view); } final AlertDialog alrt = p.create(); alrt.setIcon(R.drawable.ic_launcher_market); alrt.setTitle(getString(R.string.about_title)); alrt.setButton(AlertDialog.BUTTON_NEUTRAL, getString(R.string.about_website), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { Uri uri = Uri.parse("https://f-droid.org"); startActivity(new Intent(Intent.ACTION_VIEW, uri)); } }); alrt.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { } }); alrt.show(); return true; } return super.onOptionsItemSelected(item); }
From source file:android.support.v14.preference.PreferenceFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final TypedValue tv = new TypedValue(); getActivity().getTheme().resolveAttribute(android.support.v7.preference.R.attr.preferenceTheme, tv, true); final int theme = tv.resourceId; if (theme <= 0) { throw new IllegalStateException("Must specify preferenceTheme in theme"); }// ww w . j a va 2 s .co m mStyledContext = new ContextThemeWrapper(getActivity(), theme); mPreferenceManager = new PreferenceManager(mStyledContext); mPreferenceManager.setOnNavigateToScreenListener(this); final Bundle args = getArguments(); final String rootKey; if (args != null) { rootKey = getArguments().getString(ARG_PREFERENCE_ROOT); } else { rootKey = null; } onCreatePreferences(savedInstanceState, rootKey); }
From source file:org.ciasaboark.tacere.activity.fragment.AdvancedSettingsFragment.java
private void drawLookaheadWidgets() { LinearLayout lookaheadBox = (LinearLayout) rootView.findViewById(R.id.advanced_settings_lookahead_box); lookaheadBox.setOnClickListener(new View.OnClickListener() { @Override// w ww . j av a 2 s. co m public void onClick(View v) { final String[] intervals = Intervals.names(); AlertDialog.Builder builder = new AlertDialog.Builder( new ContextThemeWrapper(context, R.style.Dialog)); builder.setTitle(R.string.advanced_settings_section_intervals_lookahead); builder.setSingleChoiceItems(intervals, -1, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { String intervalString = intervals[i]; int intervalValue = Intervals.getIntForStringValue(intervalString); Intervals interval = Intervals.getTypeForInt(intervalValue); prefs.setLookaheadDays(interval); drawLookaheadWidgets(); } }); builder.setNeutralButton(R.string.close, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { //do nothing } }); AlertDialog dialog = builder.show(); } }); // the lookahead interval button TextView lookaheadTV = (TextView) rootView.findViewById(R.id.lookaheadDaysDescription); String lookaheadText = getResources() .getString(R.string.advanced_settings_section_intervals_lookahead_duration); lookaheadTV.setText(String.format(lookaheadText, prefs.getLookaheadDays().injectString)); }
From source file:com.andybotting.tramhunter.activity.HomeActivity.java
/** * Show the about dialog//from w w w . j a va 2s . co m */ public void showAbout() { // Get the package name String heading = getResources().getText(R.string.app_name).toString(); try { PackageInfo pi = getPackageManager().getPackageInfo(getPackageName(), 0); heading += " v" + pi.versionName + ""; } catch (NameNotFoundException e) { e.printStackTrace(); } // Build alert dialog, using a ContextThemeWrapper for proper theming AlertDialog.Builder dialogBuilder = new AlertDialog.Builder( new ContextThemeWrapper(this, R.style.AlertDialog)); View aboutView = View.inflate(new ContextThemeWrapper(this, R.style.AlertDialog), R.layout.dialog_about, null); dialogBuilder.setTitle(heading); dialogBuilder.setView(aboutView); dialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { mPreferenceHelper.setFirstLaunchThisVersion(); } }); dialogBuilder.setCancelable(false); dialogBuilder.setIcon(R.drawable.icon); dialogBuilder.show(); }
From source file:com.farmerbb.taskbar.service.TaskbarService.java
@SuppressLint("RtlHardcoded") private void drawTaskbar() { IconCache.getInstance(this).clearCache(); // Initialize layout params windowManager = (WindowManager) getSystemService(WINDOW_SERVICE); U.setCachedRotation(windowManager.getDefaultDisplay().getRotation()); final WindowManager.LayoutParams params = new WindowManager.LayoutParams( WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_PHONE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, PixelFormat.TRANSLUCENT);//from w ww . ja v a 2s. co m // Determine where to show the taskbar on screen switch (U.getTaskbarPosition(this)) { case "bottom_left": layoutId = R.layout.taskbar_left; params.gravity = Gravity.BOTTOM | Gravity.LEFT; positionIsVertical = false; break; case "bottom_vertical_left": layoutId = R.layout.taskbar_vertical; params.gravity = Gravity.BOTTOM | Gravity.LEFT; positionIsVertical = true; break; case "bottom_right": layoutId = R.layout.taskbar_right; params.gravity = Gravity.BOTTOM | Gravity.RIGHT; positionIsVertical = false; break; case "bottom_vertical_right": layoutId = R.layout.taskbar_vertical; params.gravity = Gravity.BOTTOM | Gravity.RIGHT; positionIsVertical = true; break; case "top_left": layoutId = R.layout.taskbar_left; params.gravity = Gravity.TOP | Gravity.LEFT; positionIsVertical = false; break; case "top_vertical_left": layoutId = R.layout.taskbar_top_vertical; params.gravity = Gravity.TOP | Gravity.LEFT; positionIsVertical = true; break; case "top_right": layoutId = R.layout.taskbar_right; params.gravity = Gravity.TOP | Gravity.RIGHT; positionIsVertical = false; break; case "top_vertical_right": layoutId = R.layout.taskbar_top_vertical; params.gravity = Gravity.TOP | Gravity.RIGHT; positionIsVertical = true; break; } // Initialize views int theme = 0; SharedPreferences pref = U.getSharedPreferences(this); switch (pref.getString("theme", "light")) { case "light": theme = R.style.AppTheme; break; case "dark": theme = R.style.AppTheme_Dark; break; } boolean altButtonConfig = pref.getBoolean("alt_button_config", false); ContextThemeWrapper wrapper = new ContextThemeWrapper(this, theme); layout = (LinearLayout) LayoutInflater.from(wrapper).inflate(layoutId, null); taskbar = (LinearLayout) layout.findViewById(R.id.taskbar); scrollView = (FrameLayout) layout.findViewById(R.id.taskbar_scrollview); if (altButtonConfig) { space = (Space) layout.findViewById(R.id.space_alt); layout.findViewById(R.id.space).setVisibility(View.GONE); } else { space = (Space) layout.findViewById(R.id.space); layout.findViewById(R.id.space_alt).setVisibility(View.GONE); } space.setOnClickListener(v -> toggleTaskbar()); startButton = (ImageView) layout.findViewById(R.id.start_button); int padding; if (pref.getBoolean("app_drawer_icon", false)) { startButton.setImageDrawable(ContextCompat.getDrawable(this, R.mipmap.ic_launcher)); padding = getResources().getDimensionPixelSize(R.dimen.app_drawer_icon_padding_alt); } else { startButton.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.all_apps_button_icon)); padding = getResources().getDimensionPixelSize(R.dimen.app_drawer_icon_padding); } startButton.setPadding(padding, padding, padding, padding); startButton.setOnClickListener(ocl); startButton.setOnLongClickListener(view -> { openContextMenu(); return true; }); startButton.setOnGenericMotionListener((view, motionEvent) -> { if (motionEvent.getAction() == MotionEvent.ACTION_BUTTON_PRESS && motionEvent.getButtonState() == MotionEvent.BUTTON_SECONDARY) openContextMenu(); return false; }); refreshInterval = (int) (Float.parseFloat(pref.getString("refresh_frequency", "2")) * 1000); if (refreshInterval == 0) refreshInterval = 100; sortOrder = pref.getString("sort_order", "false"); runningAppsOnly = pref.getString("recents_amount", "past_day").equals("running_apps_only"); switch (pref.getString("recents_amount", "past_day")) { case "past_day": searchInterval = System.currentTimeMillis() - AlarmManager.INTERVAL_DAY; break; case "app_start": long oneDayAgo = System.currentTimeMillis() - AlarmManager.INTERVAL_DAY; long appStartTime = pref.getLong("time_of_service_start", System.currentTimeMillis()); long deviceStartTime = System.currentTimeMillis() - SystemClock.elapsedRealtime(); long startTime = deviceStartTime > appStartTime ? deviceStartTime : appStartTime; searchInterval = startTime > oneDayAgo ? startTime : oneDayAgo; break; } Intent intent = new Intent("com.farmerbb.taskbar.HIDE_START_MENU"); LocalBroadcastManager.getInstance(TaskbarService.this).sendBroadcast(intent); if (altButtonConfig) { button = (Button) layout.findViewById(R.id.hide_taskbar_button_alt); layout.findViewById(R.id.hide_taskbar_button).setVisibility(View.GONE); } else { button = (Button) layout.findViewById(R.id.hide_taskbar_button); layout.findViewById(R.id.hide_taskbar_button_alt).setVisibility(View.GONE); } try { button.setTypeface(Typeface.createFromFile("/system/fonts/Roboto-Regular.ttf")); } catch (RuntimeException e) { /* Gracefully fail */ } updateButton(false); button.setOnClickListener(v -> toggleTaskbar()); LinearLayout buttonLayout = (LinearLayout) layout.findViewById( altButtonConfig ? R.id.hide_taskbar_button_layout_alt : R.id.hide_taskbar_button_layout); if (buttonLayout != null) buttonLayout.setOnClickListener(v -> toggleTaskbar()); LinearLayout buttonLayoutToHide = (LinearLayout) layout.findViewById( altButtonConfig ? R.id.hide_taskbar_button_layout : R.id.hide_taskbar_button_layout_alt); if (buttonLayoutToHide != null) buttonLayoutToHide.setVisibility(View.GONE); int backgroundTint = U.getBackgroundTint(this); int accentColor = U.getAccentColor(this); dashboardButton = (FrameLayout) layout.findViewById(R.id.dashboard_button); navbarButtons = (LinearLayout) layout.findViewById(R.id.navbar_buttons); dashboardEnabled = pref.getBoolean("dashboard", false); if (dashboardEnabled) { layout.findViewById(R.id.square1).setBackgroundColor(accentColor); layout.findViewById(R.id.square2).setBackgroundColor(accentColor); layout.findViewById(R.id.square3).setBackgroundColor(accentColor); layout.findViewById(R.id.square4).setBackgroundColor(accentColor); layout.findViewById(R.id.square5).setBackgroundColor(accentColor); layout.findViewById(R.id.square6).setBackgroundColor(accentColor); dashboardButton.setOnClickListener(v -> LocalBroadcastManager.getInstance(TaskbarService.this) .sendBroadcast(new Intent("com.farmerbb.taskbar.TOGGLE_DASHBOARD"))); } else dashboardButton.setVisibility(View.GONE); if (pref.getBoolean("button_back", false)) { navbarButtonsEnabled = true; ImageView backButton = (ImageView) layout.findViewById(R.id.button_back); backButton.setVisibility(View.VISIBLE); backButton.setOnClickListener(v -> { U.sendAccessibilityAction(this, AccessibilityService.GLOBAL_ACTION_BACK); if (pref.getBoolean("hide_taskbar", true) && !FreeformHackHelper.getInstance().isInFreeformWorkspace()) hideTaskbar(true); }); } if (pref.getBoolean("button_home", false)) { navbarButtonsEnabled = true; ImageView homeButton = (ImageView) layout.findViewById(R.id.button_home); homeButton.setVisibility(View.VISIBLE); homeButton.setOnClickListener(v -> { U.sendAccessibilityAction(this, AccessibilityService.GLOBAL_ACTION_HOME); if (pref.getBoolean("hide_taskbar", true) && !FreeformHackHelper.getInstance().isInFreeformWorkspace()) hideTaskbar(true); }); homeButton.setOnLongClickListener(v -> { Intent voiceSearchIntent = new Intent(RecognizerIntent.ACTION_VOICE_SEARCH_HANDS_FREE); voiceSearchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try { startActivity(voiceSearchIntent); } catch (ActivityNotFoundException e) { /* Gracefully fail */ } if (pref.getBoolean("hide_taskbar", true) && !FreeformHackHelper.getInstance().isInFreeformWorkspace()) hideTaskbar(true); return true; }); homeButton.setOnGenericMotionListener((view13, motionEvent) -> { if (motionEvent.getAction() == MotionEvent.ACTION_BUTTON_PRESS && motionEvent.getButtonState() == MotionEvent.BUTTON_SECONDARY) { Intent voiceSearchIntent = new Intent(RecognizerIntent.ACTION_VOICE_SEARCH_HANDS_FREE); voiceSearchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try { startActivity(voiceSearchIntent); } catch (ActivityNotFoundException e) { /* Gracefully fail */ } if (pref.getBoolean("hide_taskbar", true) && !FreeformHackHelper.getInstance().isInFreeformWorkspace()) hideTaskbar(true); } return true; }); } if (pref.getBoolean("button_recents", false)) { navbarButtonsEnabled = true; ImageView recentsButton = (ImageView) layout.findViewById(R.id.button_recents); recentsButton.setVisibility(View.VISIBLE); recentsButton.setOnClickListener(v -> { U.sendAccessibilityAction(this, AccessibilityService.GLOBAL_ACTION_RECENTS); if (pref.getBoolean("hide_taskbar", true) && !FreeformHackHelper.getInstance().isInFreeformWorkspace()) hideTaskbar(true); }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { recentsButton.setOnLongClickListener(v -> { U.sendAccessibilityAction(this, AccessibilityService.GLOBAL_ACTION_TOGGLE_SPLIT_SCREEN); if (pref.getBoolean("hide_taskbar", true) && !FreeformHackHelper.getInstance().isInFreeformWorkspace()) hideTaskbar(true); return true; }); recentsButton.setOnGenericMotionListener((view13, motionEvent) -> { if (motionEvent.getAction() == MotionEvent.ACTION_BUTTON_PRESS && motionEvent.getButtonState() == MotionEvent.BUTTON_SECONDARY) { U.sendAccessibilityAction(this, AccessibilityService.GLOBAL_ACTION_TOGGLE_SPLIT_SCREEN); if (pref.getBoolean("hide_taskbar", true) && !FreeformHackHelper.getInstance().isInFreeformWorkspace()) hideTaskbar(true); } return true; }); } } if (!navbarButtonsEnabled) navbarButtons.setVisibility(View.GONE); layout.setBackgroundColor(backgroundTint); layout.findViewById(R.id.divider).setBackgroundColor(accentColor); button.setTextColor(accentColor); if (isFirstStart && FreeformHackHelper.getInstance().isInFreeformWorkspace()) showTaskbar(false); else if (!pref.getBoolean("collapsed", false) && pref.getBoolean("taskbar_active", false)) toggleTaskbar(); LocalBroadcastManager.getInstance(this).unregisterReceiver(showReceiver); LocalBroadcastManager.getInstance(this).unregisterReceiver(hideReceiver); LocalBroadcastManager.getInstance(this).unregisterReceiver(tempShowReceiver); LocalBroadcastManager.getInstance(this).unregisterReceiver(tempHideReceiver); LocalBroadcastManager.getInstance(this).registerReceiver(showReceiver, new IntentFilter("com.farmerbb.taskbar.SHOW_TASKBAR")); LocalBroadcastManager.getInstance(this).registerReceiver(hideReceiver, new IntentFilter("com.farmerbb.taskbar.HIDE_TASKBAR")); LocalBroadcastManager.getInstance(this).registerReceiver(tempShowReceiver, new IntentFilter("com.farmerbb.taskbar.TEMP_SHOW_TASKBAR")); LocalBroadcastManager.getInstance(this).registerReceiver(tempHideReceiver, new IntentFilter("com.farmerbb.taskbar.TEMP_HIDE_TASKBAR")); startRefreshingRecents(); windowManager.addView(layout, params); isFirstStart = false; }
From source file:rikka.materialpreference.PreferenceFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { TypedArray a = mStyledContext.obtainStyledAttributes(null, R.styleable.PreferenceFragment, R.attr.preferenceFragmentStyle, 0); mLayoutResId = a.getResourceId(R.styleable.PreferenceFragment_android_layout, mLayoutResId); final Drawable divider = a.getDrawable(R.styleable.PreferenceFragment_android_divider); final int dividerHeight = a.getInt(R.styleable.PreferenceFragment_android_dividerHeight, -1); a.recycle();/*from ww w . j a v a 2 s.c o m*/ // Need to theme the inflater to pick up the preferenceFragmentListStyle final TypedValue tv = new TypedValue(); getActivity().getTheme().resolveAttribute(R.attr.preferenceTheme, tv, true); final int theme = tv.resourceId; final Context themedContext = new ContextThemeWrapper(inflater.getContext(), theme); final LayoutInflater themedInflater = inflater.cloneInContext(themedContext); final View view = themedInflater.inflate(mLayoutResId, container, false); final View rawListContainer = view.findViewById(R.id.list_container); if (!(rawListContainer instanceof ViewGroup)) { throw new RuntimeException( "Content has view with id attribute 'R.id.list_container' " + "that is not a ViewGroup class"); } final ViewGroup listContainer = (ViewGroup) rawListContainer; final RecyclerView listView = onCreateRecyclerView(themedInflater, listContainer, savedInstanceState); if (listView == null) { throw new RuntimeException("Could not create RecyclerView"); } mList = listView; mDividerDecoration = onCreateItemDecoration(); if (mDividerDecoration != null) { mList.addItemDecoration(mDividerDecoration); } setDivider(divider); if (dividerHeight != -1) { setDividerHeight(dividerHeight); } listContainer.addView(mList); mHandler.post(mRequestFocus); return view; }
From source file:org.solovyev.android.messenger.BaseListFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); themeContext = new ContextThemeWrapper(activity, App.getTheme().getContentThemeResId()); }
From source file:android.support.v7.preference.PreferenceFragmentCompat.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { TypedArray a = mStyledContext.obtainStyledAttributes(null, R.styleable.PreferenceFragmentCompat, R.attr.preferenceFragmentCompatStyle, 0); mLayoutResId = a.getResourceId(R.styleable.PreferenceFragmentCompat_android_layout, mLayoutResId); final Drawable divider = a.getDrawable(R.styleable.PreferenceFragmentCompat_android_divider); final int dividerHeight = a .getDimensionPixelSize(R.styleable.PreferenceFragmentCompat_android_dividerHeight, -1); a.recycle();// ww w . j a va2 s . co m // Need to theme the inflater to pick up the preferenceFragmentListStyle final TypedValue tv = new TypedValue(); getActivity().getTheme().resolveAttribute(R.attr.preferenceTheme, tv, true); final int theme = tv.resourceId; final Context themedContext = new ContextThemeWrapper(inflater.getContext(), theme); final LayoutInflater themedInflater = inflater.cloneInContext(themedContext); final View view = themedInflater.inflate(mLayoutResId, container, false); final View rawListContainer = view.findViewById(AndroidResources.ANDROID_R_LIST_CONTAINER); if (!(rawListContainer instanceof ViewGroup)) { throw new RuntimeException("Content has view with id attribute " + "'android.R.id.list_container' that is not a ViewGroup class"); } final ViewGroup listContainer = (ViewGroup) rawListContainer; final RecyclerView listView = onCreateRecyclerView(themedInflater, listContainer, savedInstanceState); if (listView == null) { throw new RuntimeException("Could not create RecyclerView"); } mList = listView; listView.addItemDecoration(mDividerDecoration); setDivider(divider); if (dividerHeight != -1) { setDividerHeight(dividerHeight); } listContainer.addView(mList); mHandler.post(mRequestFocus); return view; }