List of usage examples for java.lang.reflect Field setBoolean
@CallerSensitive @ForceInline public void setBoolean(Object obj, boolean z) throws IllegalArgumentException, IllegalAccessException
From source file:com.hzx.luoyechat.activity.MainActivity.java
@SuppressWarnings("unused") private void setOverflowButtonAlways() { try {/*from w w w .j a v a 2s . c om*/ ViewConfiguration config = ViewConfiguration.get(this); Field menuKey = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); menuKey.setAccessible(true); menuKey.setBoolean(config, false); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.gelakinetic.mtgfam.activities.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /* http://stackoverflow.com/questions/13179620/force-overflow-menu-in-actionbarsherlock/13180285 * /* w w w .java 2 s . c o m*/ * Open ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuPresenter.java, go to method reserveOverflow * Replace the original with: * public static boolean reserveOverflow(Context context) { return true; } */ if (DEVICE_VERSION >= DEVICE_HONEYCOMB) { try { ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if (menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception ex) { // Ignore } } mFragmentManager = getSupportFragmentManager(); try { pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); } catch (NameNotFoundException e) { pInfo = null; } if (prefAdapter == null) { prefAdapter = new PreferencesAdapter(this); } int lastVersion = prefAdapter.getLastVersion(); if (pInfo.versionCode != lastVersion) { // Clear the robospice cache on upgrade. This way, no cached values w/o foil prices will exist try { spiceManager.removeAllDataFromCache(); } catch (NullPointerException e) { // eat it. tasty } showDialogFragment(CHANGELOGDIALOG); prefAdapter.setLastVersion(pInfo.versionCode); bounceMenu = lastVersion <= 15; //Only bounce if the last version is 1.8.1 or lower (or a fresh install) } File mtr = new File(getFilesDir(), JudgesCornerFragment.MTR_LOCAL_FILE); File ipg = new File(getFilesDir(), JudgesCornerFragment.IPG_LOCAL_FILE); if (!mtr.exists()) { try { InputStream in = getResources().openRawResource(R.raw.mtr); FileOutputStream fos = new FileOutputStream(mtr); IOUtils.copy(in, fos); } catch (FileNotFoundException e) { Log.w("MainActivity", "MTR file could not be copied: " + e.getMessage()); } catch (IOException e) { Log.w("MainActivity", "MTR file could not be copied: " + e.getMessage()); } } if (!ipg.exists()) { try { InputStream in = getResources().openRawResource(R.raw.ipg); FileOutputStream fos = new FileOutputStream(ipg); IOUtils.copy(in, fos); } catch (FileNotFoundException e) { Log.w("MainActivity", "IPG file could not be copied: " + e.getMessage()); } catch (IOException e) { Log.w("MainActivity", "IPG file could not be copied: " + e.getMessage()); } } ActionBar actionBar = getSupportActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); actionBar.setDisplayShowTitleEnabled(false); actionBar.setIcon(R.drawable.sliding_menu_icon); SlidingMenu slidingMenu = getSlidingMenu(); slidingMenu.setBehindWidthRes(R.dimen.sliding_menu_width); slidingMenu.setBehindScrollScale(0.0f); slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); slidingMenu.setShadowWidthRes(R.dimen.shadow_width); slidingMenu.setShadowDrawable(R.drawable.sliding_menu_shadow); setSlidingActionBarEnabled(false); setBehindContentView(R.layout.fragment_menu); me = this; boolean autoupdate = prefAdapter.getAutoUpdate(); if (autoupdate) { // Only update the banning list if it hasn't been updated recently long curTime = new Date().getTime(); int updatefrequency = Integer.valueOf(prefAdapter.getUpdateFrequency()); int lastLegalityUpdate = prefAdapter.getLastLegalityUpdate(); // days to ms if (((curTime / 1000) - lastLegalityUpdate) > (updatefrequency * 24 * 60 * 60)) { startService(new Intent(this, DbUpdaterService.class)); } } timerHandler = new Handler(); registerReceiver(endTimeReceiver, new IntentFilter(RoundTimerFragment.RESULT_FILTER)); registerReceiver(startTimeReceiver, new IntentFilter(RoundTimerService.START_FILTER)); registerReceiver(cancelTimeReceiver, new IntentFilter(RoundTimerService.CANCEL_FILTER)); updatingDisplay = false; timeShowing = false; getSlidingMenu().setOnOpenedListener(new OnOpenedListener() { @Override public void onOpened() { // Close the keyboard if the slidingMenu is opened hideKeyboard(); } }); setContentView(R.layout.fragment_activity); getSupportFragmentManager().beginTransaction().replace(R.id.frag_menu, new MenuFragment()).commit(); showOnePane(); if (findViewById(R.id.middle_container) != null) { // The detail container view will be present only in the // large-screen layouts (res/values-large and // res/values-sw600dp). If this view is present, then the // activity should be in two-pane mode. mIsATablet = true; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { mThreePane = true; } else { mThreePane = false; } } else { mThreePane = false; mIsATablet = false; if (findViewById(R.id.middle_container) != null) { findViewById(R.id.middle_container).setVisibility(View.GONE); findViewById(R.id.right_container).setVisibility(View.GONE); } } Intent intent = getIntent(); if (savedInstanceState == null) { try { if (intent.getAction().equals(Intent.ACTION_VIEW)) { //apparently this can NPE on 4.3. because why not. if we catch it, launch the default frag // handles a click on a search suggestion; launches activity to show word Uri u = intent.getData(); long id = Long.parseLong(u.getLastPathSegment()); // add a fragment Bundle args = new Bundle(); args.putBoolean("isSingle", true); args.putLong("id", id); CardViewFragment rlFrag = new CardViewFragment(); rlFrag.setArguments(args); attachSingleFragment(rlFrag, "left_frag", false, false); showOnePane(); hideKeyboard(); } else if (intent.getAction().equals(Intent.ACTION_SEARCH)) { boolean consolidate = prefAdapter.getConsolidateSearch(); String query = intent.getStringExtra(SearchManager.QUERY); SearchCriteria sc = new SearchCriteria(); sc.Name = query; sc.Set_Logic = (consolidate ? CardDbAdapter.FIRSTPRINTING : CardDbAdapter.ALLPRINTINGS); // add a fragment Bundle args = new Bundle(); args.putBoolean(SearchViewFragment.RANDOM, false); args.putSerializable(SearchViewFragment.CRITERIA, sc); if (mIsATablet) { SearchViewFragment svFrag = new SearchViewFragment(); svFrag.setArguments(args); attachSingleFragment(svFrag, "left_frag", false, false); } else { ResultListFragment rlFrag = new ResultListFragment(); rlFrag.setArguments(args); attachSingleFragment(rlFrag, "left_frag", false, false); } hideKeyboard(); } else if (intent.getAction().equals(ACTION_FULL_SEARCH)) { attachSingleFragment(new SearchViewFragment(), "left_frag", false, false); showOnePane(); } else if (intent.getAction().equals(ACTION_WIDGET_SEARCH)) { attachSingleFragment(new SearchWidgetFragment(), "left_frag", false, false); showOnePane(); } else if (intent.getAction().equals(ACTION_ROUND_TIMER)) { attachSingleFragment(new RoundTimerFragment(), "left_frag", false, false); showOnePane(); } else { launchDefaultFragment(); } } catch (NullPointerException e) { launchDefaultFragment(); } } }
From source file:com.nonninz.robomodel.RoboModel.java
private void loadField(Field field, Cursor query) throws DatabaseNotUpToDateException { final Class<?> type = field.getType(); final boolean wasAccessible = field.isAccessible(); final int columnIndex = query.getColumnIndex(field.getName()); field.setAccessible(true);/*from w w w .j a va2 s. c o m*/ /* * TODO: There is the potential of a problem here: * What happens if the developer changes the type of a field between releases? * * If he saves first, then the column type will be changed (In the future). * If he loads first, we don't know if an Exception will be thrown if the * types are incompatible, because it's undocumented in the Cursor documentation. */ try { if (type == String.class) { field.set(this, query.getString(columnIndex)); } else if (type == Boolean.TYPE) { final boolean value = query.getInt(columnIndex) == 1 ? true : false; field.setBoolean(this, value); } else if (type == Byte.TYPE) { field.setByte(this, (byte) query.getShort(columnIndex)); } else if (type == Double.TYPE) { field.setDouble(this, query.getDouble(columnIndex)); } else if (type == Float.TYPE) { field.setFloat(this, query.getFloat(columnIndex)); } else if (type == Integer.TYPE) { field.setInt(this, query.getInt(columnIndex)); } else if (type == Long.TYPE) { field.setLong(this, query.getLong(columnIndex)); } else if (type == Short.TYPE) { field.setShort(this, query.getShort(columnIndex)); } else if (type.isEnum()) { final String string = query.getString(columnIndex); if (string != null && string.length() > 0) { final Object[] constants = type.getEnumConstants(); final Method method = type.getMethod("valueOf", Class.class, String.class); final Object value = method.invoke(constants[0], type, string); field.set(this, value); } } else { // Try to de-json it (db column must be of type text) try { final Object value = mMapper.readValue(query.getString(columnIndex), field.getType()); field.set(this, value); } catch (final Exception e) { final String msg = String.format("Type %s is not supported for field %s", type, field.getName()); Ln.w(e, msg); throw new IllegalArgumentException(msg); } } } catch (final IllegalAccessException e) { final String msg = String.format("Field %s is not accessible", type, field.getName()); throw new IllegalArgumentException(msg); } catch (final NoSuchMethodException e) { // Should not happen throw new RuntimeException(e); } catch (final InvocationTargetException e) { // Should not happen throw new RuntimeException(e); } catch (IllegalStateException e) { // This is when there is no column in db, but there is in the model throw new DatabaseNotUpToDateException(e); } finally { field.setAccessible(wasAccessible); } }
From source file:com.klinker.android.twitter.activities.profile_viewer.ProfilePager.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); overridePendingTransition(R.anim.activity_slide_up, R.anim.activity_slide_down); mCache = App.getInstance(this).getBitmapCache(); context = this; sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences", 0); settings = AppSettings.getInstance(this); try {//from www . j a va 2s . c om ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if (menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception ex) { // Ignore } if (getIntent().getBooleanExtra("from_widget", false) || ((settings.advanceWindowed && !getIntent().getBooleanExtra("long_click", false)) || !settings.advanceWindowed && getIntent().getBooleanExtra("long_click", false))) { setUpWindow(); } setUpTheme(); int currentOrientation = getResources().getConfiguration().orientation; if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); } getFromIntent(); setContentView(R.layout.tweet_pager); ViewPager pager = (ViewPager) findViewById(R.id.pager); ProfilePagerAdapter mPagerAdapter = new ProfilePagerAdapter(getFragmentManager(), context, name, screenName, proPic, tweetId, isRetweet, isMyProfile); pager.setAdapter(mPagerAdapter); pager.setOffscreenPageLimit(3); if (settings.addonTheme) { PagerTitleStrip strip = (PagerTitleStrip) findViewById(R.id.pager_title_strip); strip.setBackgroundColor(settings.pagerTitleInt); if (!settings.showTitleStrip) { strip.setVisibility(View.GONE); } } Utils.setActionBar(context, !settings.advanceWindowed); // set it to the profile pager.setCurrentItem(1); }
From source file:com.klinker.android.twitter.ui.profile_viewer.ProfilePager.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); overridePendingTransition(R.anim.activity_slide_up, R.anim.activity_slide_down); mCache = App.getInstance(this).getBitmapCache(); context = this; sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences", Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE); settings = AppSettings.getInstance(this); try {/*from www. j a v a2s . c o m*/ ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if (menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception ex) { // Ignore } if (getIntent().getBooleanExtra("from_widget", false) || ((settings.advanceWindowed && !getIntent().getBooleanExtra("long_click", false)) || !settings.advanceWindowed && getIntent().getBooleanExtra("long_click", false))) { setUpWindow(); } setUpTheme(); int currentOrientation = getResources().getConfiguration().orientation; if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); } getFromIntent(); setContentView(R.layout.tweet_pager); ViewPager pager = (ViewPager) findViewById(R.id.pager); ProfilePagerAdapter mPagerAdapter = new ProfilePagerAdapter(getFragmentManager(), context, name, screenName, proPic, tweetId, isRetweet, isMyProfile); pager.setAdapter(mPagerAdapter); pager.setOffscreenPageLimit(3); if (settings.addonTheme) { PagerTitleStrip strip = (PagerTitleStrip) findViewById(R.id.pager_title_strip); strip.setBackgroundColor(settings.pagerTitleInt); if (!settings.showTitleStrip) { strip.setVisibility(View.GONE); } } Utils.setActionBar(context, !settings.advanceWindowed); // set it to the profile pager.setCurrentItem(1); }
From source file:com.dngames.mobilewebcam.PhotoSettings.java
@Override public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { if (key == "cam_refresh") { int new_refresh = getEditInt(mContext, prefs, "cam_refresh", 60); String msg = "Camera refresh set to " + new_refresh + " seconds!"; if (MobileWebCam.gIsRunning) { if (!mNoToasts && new_refresh != mRefreshDuration) { try { Toast.makeText(mContext.getApplicationContext(), msg, Toast.LENGTH_SHORT).show(); } catch (RuntimeException e) { e.printStackTrace(); }//from ww w . j a v a2 s . c om } } else if (new_refresh != mRefreshDuration) { MobileWebCam.LogI(msg); } } // get all preferences for (Field f : getClass().getFields()) { { BooleanPref bp = f.getAnnotation(BooleanPref.class); if (bp != null) { try { f.setBoolean(this, prefs.getBoolean(bp.key(), bp.val())); } catch (Exception e) { Log.e("MobileWebCam", "Exception: " + bp.key() + " <- " + bp.val()); e.printStackTrace(); } } } { EditIntPref ip = f.getAnnotation(EditIntPref.class); if (ip != null) { try { int eval = getEditInt(mContext, prefs, ip.key(), ip.val()) * ip.factor(); if (ip.max() != Integer.MAX_VALUE) eval = Math.min(eval, ip.max()); if (ip.min() != Integer.MIN_VALUE) eval = Math.max(eval, ip.min()); f.setInt(this, eval); } catch (Exception e) { e.printStackTrace(); } } } { IntPref ip = f.getAnnotation(IntPref.class); if (ip != null) { try { int eval = prefs.getInt(ip.key(), ip.val()) * ip.factor(); if (ip.max() != Integer.MAX_VALUE) eval = Math.min(eval, ip.max()); if (ip.min() != Integer.MIN_VALUE) eval = Math.max(eval, ip.min()); f.setInt(this, eval); } catch (Exception e) { // handle wrong set class e.printStackTrace(); Editor edit = prefs.edit(); edit.remove(ip.key()); edit.putInt(ip.key(), ip.val()); edit.commit(); try { f.setInt(this, ip.val()); } catch (IllegalArgumentException e1) { e1.printStackTrace(); } catch (IllegalAccessException e1) { e1.printStackTrace(); } } } } { EditFloatPref fp = f.getAnnotation(EditFloatPref.class); if (fp != null) { try { float eval = getEditFloat(mContext, prefs, fp.key(), fp.val()); if (fp.max() != Float.MAX_VALUE) eval = Math.min(eval, fp.max()); if (fp.min() != Float.MIN_VALUE) eval = Math.max(eval, fp.min()); f.setFloat(this, eval); } catch (Exception e) { e.printStackTrace(); } } } { StringPref sp = f.getAnnotation(StringPref.class); if (sp != null) { try { f.set(this, prefs.getString(sp.key(), getDefaultString(mContext, sp))); } catch (Exception e) { e.printStackTrace(); } } } } mCustomImageScale = Enum.valueOf(ImageScaleMode.class, prefs.getString("custompicscale", "CROP")); mAutoStart = prefs.getBoolean("autostart", false); mCameraStartupEnabled = prefs.getBoolean("cam_autostart", true); mShutterSound = prefs.getBoolean("shutter", true); mDateTimeColor = GetPrefColor(prefs, "datetime_color", "#FFFFFFFF", Color.WHITE); mDateTimeShadowColor = GetPrefColor(prefs, "datetime_shadowcolor", "#FF000000", Color.BLACK); mDateTimeBackgroundColor = GetPrefColor(prefs, "datetime_backcolor", "#80FF0000", Color.argb(0x80, 0xFF, 0x00, 0x00)); mDateTimeBackgroundLine = prefs.getBoolean("datetime_fillline", true); mDateTimeX = prefs.getInt("datetime_x", 98); mDateTimeY = prefs.getInt("datetime_y", 98); mDateTimeAlign = Paint.Align.valueOf(prefs.getString("datetime_imprintalign", "RIGHT")); mDateTimeFontScale = (float) prefs.getInt("datetime_fontsize", 6); mTextColor = GetPrefColor(prefs, "text_color", "#FFFFFFFF", Color.WHITE); mTextShadowColor = GetPrefColor(prefs, "text_shadowcolor", "#FF000000", Color.BLACK); mTextBackgroundColor = GetPrefColor(prefs, "text_backcolor", "#80FF0000", Color.argb(0x80, 0xFF, 0x00, 0x00)); mTextBackgroundLine = prefs.getBoolean("text_fillline", true); mTextX = prefs.getInt("text_x", 2); mTextY = prefs.getInt("text_y", 2); mTextAlign = Paint.Align.valueOf(prefs.getString("text_imprintalign", "LEFT")); mTextFontScale = (float) prefs.getInt("infotext_fontsize", 6); mTextFontname = prefs.getString("infotext_fonttypeface", ""); mStatusInfoColor = GetPrefColor(prefs, "statusinfo_color", "#FFFFFFFF", Color.WHITE); mStatusInfoShadowColor = GetPrefColor(prefs, "statusinfo_shadowcolor", "#FF000000", Color.BLACK); mStatusInfoX = prefs.getInt("statusinfo_x", 2); mStatusInfoY = prefs.getInt("statusinfo_y", 98); mStatusInfoAlign = Paint.Align.valueOf(prefs.getString("statusinfo_imprintalign", "LEFT")); mStatusInfoBackgroundColor = GetPrefColor(prefs, "statusinfo_backcolor", "#00000000", Color.TRANSPARENT); mStatusInfoFontScale = (float) prefs.getInt("statusinfo_fontsize", 6); mStatusInfoBackgroundLine = prefs.getBoolean("statusinfo_fillline", false); mGPSColor = GetPrefColor(prefs, "gps_color", "#FFFFFFFF", Color.WHITE); mGPSShadowColor = GetPrefColor(prefs, "gps_shadowcolor", "#FF000000", Color.BLACK); mGPSX = prefs.getInt("gps_x", 98); mGPSY = prefs.getInt("gps_y", 2); mGPSAlign = Paint.Align.valueOf(prefs.getString("gps_imprintalign", "RIGHT")); mGPSBackgroundColor = GetPrefColor(prefs, "gps_backcolor", "#00000000", Color.TRANSPARENT); mGPSFontScale = (float) prefs.getInt("gps_fontsize", 6); mGPSBackgroundLine = prefs.getBoolean("gps_fillline", false); mImprintPictureX = prefs.getInt("imprint_picture_x", 0); mImprintPictureY = prefs.getInt("imprint_picture_y", 0); mNightAutoConfigEnabled = prefs.getBoolean("night_auto_enabled", false); mSetNightConfiguration = prefs.getBoolean("cam_nightconfiguration", false); // override night camera parameters (read again with postfix) getCurrentNightSettings(); mFilterPicture = false; //***prefs.getBoolean("filter_picture", false); mFilterType = getEditInt(mContext, prefs, "filter_sel", 0); if (mImprintPicture) { if (mImprintPictureURL.length() == 0) { // sdcard image File path = new File(Environment.getExternalStorageDirectory() + "/MobileWebCam/"); if (path.exists()) { synchronized (gImprintBitmapLock) { if (gImprintBitmap != null) gImprintBitmap.recycle(); gImprintBitmap = null; File file = new File(path, "imprint.png"); try { FileInputStream in = new FileInputStream(file); gImprintBitmap = BitmapFactory.decodeStream(in); in.close(); } catch (IOException e) { Toast.makeText(mContext, "Error: unable to read imprint bitmap " + file.getName() + "!", Toast.LENGTH_SHORT).show(); gImprintBitmap = null; } catch (OutOfMemoryError e) { Toast.makeText(mContext, "Error: imprint bitmap " + file.getName() + " too large!", Toast.LENGTH_LONG).show(); gImprintBitmap = null; } } } } else { DownloadImprintBitmap(); } synchronized (gImprintBitmapLock) { if (gImprintBitmap == null) { // last resort: resource default try { gImprintBitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.imprint); } catch (OutOfMemoryError e) { Toast.makeText(mContext, "Error: default imprint bitmap too large!", Toast.LENGTH_LONG) .show(); gImprintBitmap = null; } } } } mNoToasts = prefs.getBoolean("no_messages", false); mFullWakeLock = prefs.getBoolean("full_wakelock", true); switch (getEditInt(mContext, prefs, "camera_mode", 1)) { case 0: mMode = Mode.MANUAL; break; case 2: mMode = Mode.HIDDEN; break; case 3: mMode = Mode.BACKGROUND; break; case 1: default: mMode = Mode.NORMAL; break; } }
From source file:com.klinker.android.twitter.ui.compose.Compose.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); overridePendingTransition(R.anim.fade_in, R.anim.fade_out); countHandler = new Handler(); settings = AppSettings.getInstance(this); context = this; sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences", Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE); try {//from ww w . ja va 2 s . c o m ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if (menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception ex) { // Ignore } int currentOrientation = getResources().getConfiguration().orientation; if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); } currentAccount = sharedPrefs.getInt("current_account", 1); mLocationClient = new LocationClient(context, this, this); mLocationClient.connect(); Utils.setUpPopupTheme(context, settings); setUpWindow(); setUpLayout(); setUpActionBar(); setUpReplyText(); if (reply.getText().toString().contains(" RT @")) { reply.setSelection(0); } //Utils.setActionBar(context, false); if (getIntent().getBooleanExtra("start_attach", false)) { attachButton.performClick(); //overflow.performClick(); } if (notiId != 0) { HoloTextView replyTo = (HoloTextView) findViewById(R.id.reply_to); replyTo.setText(replyText); TextUtils.linkifyText(context, replyTo, null, true, "", true); replyTo.setVisibility(View.VISIBLE); } new Handler().postDelayed(new Runnable() { @Override public void run() { String text = reply.getText().toString(); try { if (!android.text.TextUtils.isEmpty(text) && !text.startsWith(" RT @")) { //text = text.replaceAll(" ", " "); reply.setText(text); reply.setSelection(text.length()); if (!text.endsWith(" ")) { reply.append(" "); } } } catch (Exception e) { } } }, 250); }
From source file:org.cryptsecure.Utility.java
/** * Force overflow menu buttons. Typically these are only available for * phones without a hardware context-menu key. * /*from ww w .j a v a2s . co m*/ * @param context * the context */ public static void forceOverflowMenuButtons(Context context) { // ========================= // how-to-force-use-of-overflow-menu-on-devices-with-menu-button try { ViewConfiguration config = ViewConfiguration.get(context); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if (menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception ex) { // Ignore } // ========================= }
From source file:com.klinker.android.twitter.activities.compose.Compose.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); overridePendingTransition(R.anim.fade_in, R.anim.fade_out); countHandler = new Handler(); settings = AppSettings.getInstance(this); context = this; sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences", 0); try {//from www . j a v a 2 s. c o m ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if (menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception ex) { // Ignore } int currentOrientation = getResources().getConfiguration().orientation; if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); } currentAccount = sharedPrefs.getInt("current_account", 1); buildGoogleApiClient(); Utils.setUpPopupTheme(context, settings); setUpWindow(); setUpLayout(); setUpActionBar(); setUpReplyText(); if (reply.getText().toString().contains(" RT @") || reply.getText().toString().contains("/status/")) { reply.setSelection(0); } if (getIntent().getBooleanExtra("start_attach", false)) { attachButton.performClick(); //overflow.performClick(); } if (notiId != 0) { HoloTextView replyTo = (HoloTextView) findViewById(R.id.reply_to); replyTo.setText(replyText); TextUtils.linkifyText(context, replyTo, null, true, "", true); replyTo.setVisibility(View.VISIBLE); } new Handler().postDelayed(new Runnable() { @Override public void run() { String text = reply.getText().toString(); try { if (!android.text.TextUtils.isEmpty(text) && !(text.startsWith(" RT @") || text.contains("/status/"))) { //text = text.replaceAll(" ", " "); reply.setText(text); reply.setSelection(text.length()); if (!text.endsWith(" ")) { reply.append(" "); } } } catch (Exception e) { } } }, 250); }
From source file:com.daiv.android.twitter.ui.compose.Compose.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); overridePendingTransition(R.anim.fade_in, R.anim.fade_out); countHandler = new Handler(); settings = AppSettings.getInstance(this); context = this; sharedPrefs = context.getSharedPreferences("com.daiv.android.twitter_world_preferences", Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE); try {//from w w w . ja v a2 s . co m ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if (menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception ex) { // Ignore } int currentOrientation = getResources().getConfiguration().orientation; if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); } currentAccount = sharedPrefs.getInt("current_account", 1); buildGoogleApiClient(); Utils.setUpPopupTheme(context, settings); setUpWindow(); setUpLayout(); setUpActionBar(); setUpReplyText(); if (reply.getText().toString().contains(" RT @") || reply.getText().toString().contains("/status/")) { reply.setSelection(0); } if (getIntent().getBooleanExtra("start_attach", false)) { attachButton.performClick(); //overflow.performClick(); } if (notiId != 0) { HoloTextView replyTo = (HoloTextView) findViewById(R.id.reply_to); replyTo.setText(replyText); TextUtils.linkifyText(context, replyTo, null, true, "", true); replyTo.setVisibility(View.VISIBLE); } new Handler().postDelayed(new Runnable() { @Override public void run() { String text = reply.getText().toString(); try { if (!android.text.TextUtils.isEmpty(text) && !(text.startsWith(" RT @") || text.contains("/status/"))) { //text = text.replaceAll(" ", " "); reply.setText(text); reply.setSelection(text.length()); if (!text.endsWith(" ")) { reply.append(" "); } } } catch (Exception e) { } } }, 250); }