List of usage examples for android.widget RelativeLayout getWidth
@ViewDebug.ExportedProperty(category = "layout") public final int getWidth()
From source file:de.tobiasbielefeld.solitaire.games.Game.java
/** * use this to automatically set up the dimensions (then the call of setUpCardWidth() isn't necessary). * It will take the layout, a value for width and a value for height. The values * represent the limiting values for the orientation. For example : There are 7 rows, so 7 * stacks have to fit on the horizontal axis, but also 4 cards in the height. The method uses * these values to calculate the right dimensions for the cards, so everything fits fine on the screen * * @param layoutGame The layout, where the cards are located in * @param cardsInRow The limiting number of card in the biggest row of the layout * @param cardsInColumn The limiting number of cards in the biggest column of the layout *///www.ja v a 2 s . com protected void setUpCardDimensions(RelativeLayout layoutGame, int cardsInRow, int cardsInColumn) { int testWidth1, testHeight1, testWidth2, testHeight2; testWidth1 = layoutGame.getWidth() / cardsInRow; testHeight1 = (int) (testWidth1 * 1.5); testHeight2 = layoutGame.getHeight() / cardsInColumn; testWidth2 = (int) (testHeight2 / 1.5); if (testHeight1 < testHeight2) { Card.width = testWidth1; Card.height = testHeight1; } else { Card.width = testWidth2; Card.height = testHeight2; } RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(Card.width, Card.height); for (Card card : cards) card.view.setLayoutParams(params); for (Stack stack : stacks) stack.view.setLayoutParams(params); }
From source file:com.sociablue.nanodegree_p1.MovieListFragment.java
private void initializeFab(View rootView) { final RelativeLayout buttonContainer = (RelativeLayout) rootView.findViewById(R.id.menu_button_container); final FloatingActionButton Fab = (FloatingActionButton) rootView.findViewById(R.id.fab); final ImageView bottomBar = (ImageView) rootView.findViewById(R.id.menu_bottom_bar); final ImageView topBar = (ImageView) rootView.findViewById(R.id.menu_top_bar); Fab.setOnClickListener(new View.OnClickListener() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override//from w w w . jav a 2s.c om public void onClick(View v) { //Menu Button Icon Animation //Setting up necessary variables long animationDuration = 500; float containerHeight = buttonContainer.getHeight(); float containerCenterY = containerHeight / 2; float containerCenterX = buttonContainer.getWidth() / 2; float topBarCenter = topBar.getTop() + topBar.getHeight() / 2; float widthOfBar = topBar.getWidth(); float heightOfBar = topBar.getHeight(); final float distanceBetweenBars = (containerCenterY - topBarCenter); /** *TODO: Refactor block of code to use Value Property Animator. Should be more efficient to animate multiple properties *and objects at the same time. Also, will try to break intialization into smaller functions. */ //Setting up animations of hamburger bars and rotation /** * Animation For Top Menu Button Icon Bar. Sliding from the top to rest on top of the middle bar. * Y Translation is 1/2 the height of the hamburger bar minus the distance. * Subtracting the distance from the height because the distance between bars is * calculated of the exact center of the button. * With out the subtraction the bar would translate slightly below the middle bar. */ float yTranslation = heightOfBar / 2 - distanceBetweenBars; float xTranslation = widthOfBar / 2 + heightOfBar / 2; TranslateAnimation topBarTranslationAnim = new TranslateAnimation(Animation.ABSOLUTE, 0f, Animation.ABSOLUTE, 0F, Animation.ABSOLUTE, 0f, Animation.ABSOLUTE, distanceBetweenBars); topBarTranslationAnim.setDuration((long) (animationDuration * 0.8)); topBarTranslationAnim.setFillAfter(true); //Animation for bottom hamburger bar. Translates and Rotates to create 'X' AnimationSet bottomBarAnimation = new AnimationSet(true); bottomBarAnimation.setFillAfter(true); //Rotate to create cross. (The cross becomes the X after the button rotation completes" RotateAnimation bottomBarRotationAnimation = new RotateAnimation(0f, 90f, Animation.RELATIVE_TO_SELF, 1f, Animation.RELATIVE_TO_SELF, 1f); bottomBarRotationAnimation.setDuration(animationDuration); bottomBarAnimation.addAnimation(bottomBarRotationAnimation); //Translate to correct X alignment TranslateAnimation bottomBarTranslationAnimation = new TranslateAnimation(Animation.ABSOLUTE, 0f, Animation.ABSOLUTE, -xTranslation, Animation.ABSOLUTE, 0f, Animation.ABSOLUTE, -yTranslation); bottomBarTranslationAnimation.setDuration(animationDuration); bottomBarAnimation.addAnimation(bottomBarTranslationAnimation); //Button Specific Animations //Rotate Button Container RotateAnimation containerRotationAnimation = new RotateAnimation(0, 135f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); containerRotationAnimation.setDuration(animationDuration); containerRotationAnimation.setFillAfter(true); //Animate change of button color between Active and Disabled colors that have been //defined in color.xml int activeColor = getResources().getColor(R.color.active_button); int disabledColor = getResources().getColor(R.color.disabled_button); //Need to use ValueAnimator because property animator does not support BackgroundTint ValueAnimator buttonColorAnimation = ValueAnimator.ofArgb(activeColor, disabledColor); buttonColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { Fab.setBackgroundTintList(ColorStateList.valueOf((int) animation.getAnimatedValue())); } }); buttonColorAnimation.setDuration(animationDuration); //Start all the animations topBar.startAnimation(topBarTranslationAnim); bottomBar.startAnimation(bottomBarAnimation); buttonContainer.startAnimation(containerRotationAnimation); buttonColorAnimation.start(); //Toogle mMenu open and closed if (mMenu.isOpen()) { //If mMenu is open, do the reverse of the animation containerRotationAnimation .setInterpolator(new ReverseInterpolator(new AccelerateInterpolator())); topBarTranslationAnim.setInterpolator(new ReverseInterpolator(new AccelerateInterpolator())); bottomBarAnimation.setInterpolator(new ReverseInterpolator(new AccelerateInterpolator())); buttonColorAnimation.setInterpolator(new ReverseInterpolator(new LinearInterpolator())); mMenu.close(); } else { bottomBarAnimation.setInterpolator(new AccelerateInterpolator()); mMenu.open(); } } }); }
From source file:com.aniruddhc.acemusic.player.LauncherActivity.LauncherActivity.java
@SuppressLint("NewApi") @Override/* ww w . j av a2 s . c o m*/ public void onCreate(Bundle savedInstanceState) { setTheme(R.style.AppThemeNoActionBar); super.onCreate(savedInstanceState); setContentView(R.layout.activity_launcher); mContext = this; mActivity = this; mApp = (Common) mContext.getApplicationContext(); mHandler = new Handler(); //Increment the start count. This value will be used to determine when the library should be rescanned. int startCount = mApp.getSharedPreferences().getInt("START_COUNT", 1); mApp.getSharedPreferences().edit().putInt("START_COUNT", startCount + 1).commit(); //Save the dimensions of the layout for later use on KitKat devices. final RelativeLayout launcherRootView = (RelativeLayout) findViewById(R.id.launcher_root_view); launcherRootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { try { int screenDimens[] = new int[2]; int screenHeight = 0; int screenWidth = 0; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { //API levels 14, 15 and 16. screenDimens = getTrueDeviceResolution(); screenWidth = screenDimens[0]; screenHeight = screenDimens[1]; } else { //API levels 17+. Display display = getWindowManager().getDefaultDisplay(); DisplayMetrics metrics = new DisplayMetrics(); display.getRealMetrics(metrics); screenHeight = metrics.heightPixels; screenWidth = metrics.widthPixels; } int layoutHeight = launcherRootView.getHeight(); int layoutWidth = launcherRootView.getWidth(); int extraHeight = screenHeight - layoutHeight; int extraWidth = screenWidth = layoutWidth; mApp.getSharedPreferences().edit().putInt("KITKAT_HEIGHT", layoutHeight).commit(); mApp.getSharedPreferences().edit().putInt("KITKAT_WIDTH", layoutWidth).commit(); mApp.getSharedPreferences().edit().putInt("KITKAT_HEIGHT_LAND", layoutWidth - extraHeight) .commit(); mApp.getSharedPreferences().edit().putInt("KITKAT_WIDTH_LAND", screenHeight).commit(); } catch (Exception e) { e.printStackTrace(); } } }); //Build the music library based on the user's scan frequency preferences. int scanFrequency = mApp.getSharedPreferences().getInt("SCAN_FREQUENCY", 5); int updatedStartCount = mApp.getSharedPreferences().getInt("START_COUNT", 1); //Launch the appropriate activity based on the "FIRST RUN" flag. if (mApp.getSharedPreferences().getBoolean(Common.FIRST_RUN, true) == true) { //Create the default Playlists directory if it doesn't exist. File playlistsDirectory = new File(Environment.getExternalStorageDirectory() + "/Playlists/"); if (!playlistsDirectory.exists() || !playlistsDirectory.isDirectory()) { playlistsDirectory.mkdir(); } //Disable equalizer for HTC devices by default. if (mApp.getSharedPreferences().getBoolean(Common.FIRST_RUN, true) == true && Build.PRODUCT.contains("HTC")) { mApp.getSharedPreferences().edit().putBoolean("EQUALIZER_ENABLED", false).commit(); } //Send out a test broadcast to initialize the homescreen/lockscreen widgets. sendBroadcast(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME)); Intent intent = new Intent(this, WelcomeActivity.class); startActivity(intent); overridePendingTransition(R.anim.fade_in, R.anim.fade_out); } else if (mApp.isBuildingLibrary()) { buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text); buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info); buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout); buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryInfoText.setPaintFlags( buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryMainText.setPaintFlags( buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setText(R.string.jams_is_building_library); buildingLibraryLayout.setVisibility(View.VISIBLE); //Initialize the runnable that will fire once the scan process is complete. mHandler.post(scanFinishedCheckerRunnable); } else if (mApp.getSharedPreferences().getBoolean("RESCAN_ALBUM_ART", false) == true) { buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text); buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info); buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout); buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryInfoText.setPaintFlags( buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryMainText.setPaintFlags( buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setText(R.string.jams_is_caching_artwork); initScanProcess(0); } else if ((mApp.getSharedPreferences().getBoolean("REBUILD_LIBRARY", false) == true) || (scanFrequency == 0 && mApp.isScanFinished() == false) || (scanFrequency == 1 && mApp.isScanFinished() == false && updatedStartCount % 3 == 0) || (scanFrequency == 2 && mApp.isScanFinished() == false && updatedStartCount % 5 == 0) || (scanFrequency == 3 && mApp.isScanFinished() == false && updatedStartCount % 10 == 0) || (scanFrequency == 4 && mApp.isScanFinished() == false && updatedStartCount % 20 == 0)) { buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text); buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info); buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout); buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryInfoText.setPaintFlags( buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryMainText.setPaintFlags( buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); initScanProcess(1); } else { //Check if this activity was called from Settings. if (getIntent().hasExtra("UPGRADE")) { if (getIntent().getExtras().getBoolean("UPGRADE") == true) { mExplicitShowTrialFragment = true; } else { mExplicitShowTrialFragment = false; } } //initInAppBilling(); launchMainActivity(); } //Fire away a report to Google Analytics. try { if (mApp.isGoogleAnalyticsEnabled() == true) { EasyTracker easyTracker = EasyTracker.getInstance(this); easyTracker.send(MapBuilder.createEvent("ACE startup.", // Event category (required) "User started ACE.", // Event action (required) "User started ACE.", // Event label null) // Event value .build()); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.jams.music.player.LauncherActivity.LauncherActivity.java
@SuppressLint("NewApi") @Override// www .ja v a2 s. com public void onCreate(Bundle savedInstanceState) { setTheme(R.style.AppThemeNoActionBar); super.onCreate(savedInstanceState); setContentView(R.layout.activity_launcher); mContext = this; mActivity = this; mApp = (Common) mContext.getApplicationContext(); mHandler = new Handler(); //Increment the start count. This value will be used to determine when the library should be rescanned. int startCount = mApp.getSharedPreferences().getInt("START_COUNT", 1); mApp.getSharedPreferences().edit().putInt("START_COUNT", startCount + 1).commit(); //Save the dimensions of the layout for later use on KitKat devices. final RelativeLayout launcherRootView = (RelativeLayout) findViewById(R.id.launcher_root_view); launcherRootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { try { int screenDimens[] = new int[2]; int screenHeight = 0; int screenWidth = 0; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { //API levels 14, 15 and 16. screenDimens = getTrueDeviceResolution(); screenWidth = screenDimens[0]; screenHeight = screenDimens[1]; } else { //API levels 17+. Display display = getWindowManager().getDefaultDisplay(); DisplayMetrics metrics = new DisplayMetrics(); display.getRealMetrics(metrics); screenHeight = metrics.heightPixels; screenWidth = metrics.widthPixels; } int layoutHeight = launcherRootView.getHeight(); int layoutWidth = launcherRootView.getWidth(); int extraHeight = screenHeight - layoutHeight; int extraWidth = screenWidth = layoutWidth; mApp.getSharedPreferences().edit().putInt("KITKAT_HEIGHT", layoutHeight).commit(); mApp.getSharedPreferences().edit().putInt("KITKAT_WIDTH", layoutWidth).commit(); mApp.getSharedPreferences().edit().putInt("KITKAT_HEIGHT_LAND", layoutWidth - extraHeight) .commit(); mApp.getSharedPreferences().edit().putInt("KITKAT_WIDTH_LAND", screenHeight).commit(); } catch (Exception e) { e.printStackTrace(); } } }); //Build the music library based on the user's scan frequency preferences. int scanFrequency = mApp.getSharedPreferences().getInt("SCAN_FREQUENCY", 5); int updatedStartCount = mApp.getSharedPreferences().getInt("START_COUNT", 1); //Launch the appropriate activity based on the "FIRST RUN" flag. if (mApp.getSharedPreferences().getBoolean(Common.FIRST_RUN, true) == true) { //Create the default Playlists directory if it doesn't exist. File playlistsDirectory = new File(Environment.getExternalStorageDirectory() + "/Playlists/"); if (!playlistsDirectory.exists() || !playlistsDirectory.isDirectory()) { playlistsDirectory.mkdir(); } //Disable equalizer for HTC devices by default. if (mApp.getSharedPreferences().getBoolean(Common.FIRST_RUN, true) == true && Build.PRODUCT.contains("HTC")) { mApp.getSharedPreferences().edit().putBoolean("EQUALIZER_ENABLED", false).commit(); } //Send out a test broadcast to initialize the homescreen/lockscreen widgets. sendBroadcast(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME)); Intent intent = new Intent(this, WelcomeActivity.class); startActivity(intent); overridePendingTransition(R.anim.fade_in, R.anim.fade_out); } else if (mApp.isBuildingLibrary()) { buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text); buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info); buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout); buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryInfoText.setPaintFlags( buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryMainText.setPaintFlags( buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setText(R.string.jams_is_building_library); buildingLibraryLayout.setVisibility(View.VISIBLE); //Initialize the runnable that will fire once the scan process is complete. mHandler.post(scanFinishedCheckerRunnable); } else if (mApp.getSharedPreferences().getBoolean("RESCAN_ALBUM_ART", false) == true) { buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text); buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info); buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout); buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryInfoText.setPaintFlags( buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryMainText.setPaintFlags( buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setText(R.string.jams_is_caching_artwork); initScanProcess(0); } else if ((mApp.getSharedPreferences().getBoolean("REBUILD_LIBRARY", false) == true) || (scanFrequency == 0 && mApp.isScanFinished() == false) || (scanFrequency == 1 && mApp.isScanFinished() == false && updatedStartCount % 3 == 0) || (scanFrequency == 2 && mApp.isScanFinished() == false && updatedStartCount % 5 == 0) || (scanFrequency == 3 && mApp.isScanFinished() == false && updatedStartCount % 10 == 0) || (scanFrequency == 4 && mApp.isScanFinished() == false && updatedStartCount % 20 == 0)) { buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text); buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info); buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout); buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryInfoText.setPaintFlags( buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryMainText.setPaintFlags( buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); initScanProcess(1); } else { //Check if this activity was called from Settings. if (getIntent().hasExtra("UPGRADE")) { if (getIntent().getExtras().getBoolean("UPGRADE") == true) { mExplicitShowTrialFragment = true; } else { mExplicitShowTrialFragment = false; } } //initInAppBilling(); launchMainActivity(); } //Fire away a report to Google Analytics. try { if (mApp.isGoogleAnalyticsEnabled() == true) { EasyTracker easyTracker = EasyTracker.getInstance(this); easyTracker.send(MapBuilder.createEvent("Genesis Music startup.", // Event category (required) "User started Genesis Music.", // Event action (required) "User started Genesis Music.", // Event label null) // Event value .build()); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.Duo.music.player.LauncherActivity.LauncherActivity.java
@SuppressLint("NewApi") @Override//from w ww .ja v a 2s . c o m public void onCreate(Bundle savedInstanceState) { setTheme(R.style.AppThemeNoActionBar); super.onCreate(savedInstanceState); setContentView(R.layout.activity_launcher); mContext = this; mActivity = this; mApp = (Common) mContext.getApplicationContext(); mHandler = new Handler(); //Increment the start count. This value will be used to determine when the library should be rescanned. int startCount = mApp.getSharedPreferences().getInt("START_COUNT", 1); mApp.getSharedPreferences().edit().putInt("START_COUNT", startCount + 1).commit(); //Save the dimensions of the layout for later use on KitKat devices. final RelativeLayout launcherRootView = (RelativeLayout) findViewById(R.id.launcher_root_view); launcherRootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { try { int screenDimens[] = new int[2]; int screenHeight = 0; int screenWidth = 0; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { //API levels 14, 15 and 16. screenDimens = getTrueDeviceResolution(); screenWidth = screenDimens[0]; screenHeight = screenDimens[1]; } else { //API levels 17+. Display display = getWindowManager().getDefaultDisplay(); DisplayMetrics metrics = new DisplayMetrics(); display.getRealMetrics(metrics); screenHeight = metrics.heightPixels; screenWidth = metrics.widthPixels; } int layoutHeight = launcherRootView.getHeight(); int layoutWidth = launcherRootView.getWidth(); int extraHeight = screenHeight - layoutHeight; int extraWidth = screenWidth = layoutWidth; mApp.getSharedPreferences().edit().putInt("KITKAT_HEIGHT", layoutHeight).commit(); mApp.getSharedPreferences().edit().putInt("KITKAT_WIDTH", layoutWidth).commit(); mApp.getSharedPreferences().edit().putInt("KITKAT_HEIGHT_LAND", layoutWidth - extraHeight) .commit(); mApp.getSharedPreferences().edit().putInt("KITKAT_WIDTH_LAND", screenHeight).commit(); } catch (Exception e) { e.printStackTrace(); } } }); //Build the music library based on the user's scan frequency preferences. int scanFrequency = mApp.getSharedPreferences().getInt("SCAN_FREQUENCY", 5); int updatedStartCount = mApp.getSharedPreferences().getInt("START_COUNT", 1); //Launch the appropriate activity based on the "FIRST RUN" flag. if (mApp.getSharedPreferences().getBoolean(Common.FIRST_RUN, true) == true) { //Create the default Playlists directory if it doesn't exist. File playlistsDirectory = new File(Environment.getExternalStorageDirectory() + "/Playlists/"); if (!playlistsDirectory.exists() || !playlistsDirectory.isDirectory()) { playlistsDirectory.mkdir(); } //Disable equalizer for HTC devices by default. if (mApp.getSharedPreferences().getBoolean(Common.FIRST_RUN, true) == true && Build.PRODUCT.contains("HTC")) { mApp.getSharedPreferences().edit().putBoolean("EQUALIZER_ENABLED", false).commit(); } //Send out a test broadcast to initialize the homescreen/lockscreen widgets. sendBroadcast(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME)); Intent intent = new Intent(this, WelcomeActivity.class); startActivity(intent); overridePendingTransition(R.anim.fade_in, R.anim.fade_out); } else if (mApp.isBuildingLibrary()) { buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text); buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info); buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout); buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryInfoText.setPaintFlags( buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryMainText.setPaintFlags( buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setText(R.string.jams_is_building_library); buildingLibraryLayout.setVisibility(View.VISIBLE); //Initialize the runnable that will fire once the scan process is complete. mHandler.post(scanFinishedCheckerRunnable); } else if (mApp.getSharedPreferences().getBoolean("RESCAN_ALBUM_ART", false) == true) { buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text); buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info); buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout); buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryInfoText.setPaintFlags( buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryMainText.setPaintFlags( buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setText(R.string.jams_is_caching_artwork); initScanProcess(0); } else if ((mApp.getSharedPreferences().getBoolean("REBUILD_LIBRARY", false) == true) || (scanFrequency == 0 && mApp.isScanFinished() == false) || (scanFrequency == 1 && mApp.isScanFinished() == false && updatedStartCount % 3 == 0) || (scanFrequency == 2 && mApp.isScanFinished() == false && updatedStartCount % 5 == 0) || (scanFrequency == 3 && mApp.isScanFinished() == false && updatedStartCount % 10 == 0) || (scanFrequency == 4 && mApp.isScanFinished() == false && updatedStartCount % 20 == 0)) { buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text); buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info); buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout); buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryInfoText.setPaintFlags( buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryMainText.setPaintFlags( buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); initScanProcess(1); } else { //Check if this activity was called from Settings. if (getIntent().hasExtra("UPGRADE")) { if (getIntent().getExtras().getBoolean("UPGRADE") == true) { mExplicitShowTrialFragment = true; } else { mExplicitShowTrialFragment = false; } } //initInAppBilling(); launchMainActivity(); } //Fire away a report to Google Analytics. try { if (mApp.isGoogleAnalyticsEnabled() == true) { EasyTracker easyTracker = EasyTracker.getInstance(this); easyTracker.send(MapBuilder.createEvent("Jams startup.", // Event category (required) "User started Jams.", // Event action (required) "User started Jams.", // Event label null) // Event value .build()); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.jelly.music.player.LauncherActivity.LauncherActivity.java
@SuppressLint("NewApi") @Override/*from w w w . j a v a 2 s .c om*/ public void onCreate(Bundle savedInstanceState) { Parse.initialize(this, "aZiGV1G02m1Mj3SaaD9riuyrucDclK7abpc2Ibz3", "eCPoMrWrFnnHPVmBbDDIAFAMTA5EJLgtHLS2U9St"); Map<String, String> dimensions = new HashMap<String, String>(); // What type of news is this? dimensions.put("category", "politics"); // Is it a weekday or the weekend? dimensions.put("dayType", "weekday"); // Send the dimensions to Parse along with the 'read' event ParseAnalytics.trackEvent("read", dimensions); setTheme(R.style.AppThemeNoActionBar); super.onCreate(savedInstanceState); setContentView(R.layout.activity_launcher); mContext = this; mActivity = this; mApp = (Common) mContext.getApplicationContext(); mHandler = new Handler(); //Increment the start count. This value will be used to determine when the library should be rescanned. int startCount = mApp.getSharedPreferences().getInt("START_COUNT", 1); mApp.getSharedPreferences().edit().putInt("START_COUNT", startCount + 1).commit(); //Save the dimensions of the layout for later use on KitKat devices. final RelativeLayout launcherRootView = (RelativeLayout) findViewById(R.id.launcher_root_view); launcherRootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { try { int screenDimens[] = new int[2]; int screenHeight = 0; int screenWidth = 0; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { //API levels 14, 15 and 16. screenDimens = getTrueDeviceResolution(); screenWidth = screenDimens[0]; screenHeight = screenDimens[1]; } else { //API levels 17+. Display display = getWindowManager().getDefaultDisplay(); DisplayMetrics metrics = new DisplayMetrics(); display.getRealMetrics(metrics); screenHeight = metrics.heightPixels; screenWidth = metrics.widthPixels; } int layoutHeight = launcherRootView.getHeight(); int layoutWidth = launcherRootView.getWidth(); int extraHeight = screenHeight - layoutHeight; int extraWidth = screenWidth = layoutWidth; mApp.getSharedPreferences().edit().putInt("KITKAT_HEIGHT", layoutHeight).commit(); mApp.getSharedPreferences().edit().putInt("KITKAT_WIDTH", layoutWidth).commit(); mApp.getSharedPreferences().edit().putInt("KITKAT_HEIGHT_LAND", layoutWidth - extraHeight) .commit(); mApp.getSharedPreferences().edit().putInt("KITKAT_WIDTH_LAND", screenHeight).commit(); } catch (Exception e) { e.printStackTrace(); } } }); //Build the music library based on the user's scan frequency preferences. int scanFrequency = mApp.getSharedPreferences().getInt("SCAN_FREQUENCY", 5); int updatedStartCount = mApp.getSharedPreferences().getInt("START_COUNT", 1); //Launch the appropriate activity based on the "FIRST RUN" flag. if (mApp.getSharedPreferences().getBoolean(Common.FIRST_RUN, true) == true) { //Create the default Playlists directory if it doesn't exist. File playlistsDirectory = new File(Environment.getExternalStorageDirectory() + "/Playlists/"); if (!playlistsDirectory.exists() || !playlistsDirectory.isDirectory()) { playlistsDirectory.mkdir(); } //Disable equalizer for HTC devices by default. if (mApp.getSharedPreferences().getBoolean(Common.FIRST_RUN, true) == true && Build.PRODUCT.contains("HTC")) { mApp.getSharedPreferences().edit().putBoolean("EQUALIZER_ENABLED", false).commit(); } //Send out a test broadcast to initialize the homescreen/lockscreen widgets. sendBroadcast(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME)); Intent intent = new Intent(this, WelcomeActivity.class); startActivity(intent); overridePendingTransition(R.anim.fade_in, R.anim.fade_out); } else if (mApp.isBuildingLibrary()) { buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text); buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info); buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout); buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryInfoText.setPaintFlags( buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryMainText.setPaintFlags( buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setText(R.string.jams_is_building_library); buildingLibraryLayout.setVisibility(View.VISIBLE); //Initialize the runnable that will fire once the scan process is complete. mHandler.post(scanFinishedCheckerRunnable); } else if (mApp.getSharedPreferences().getBoolean("RESCAN_ALBUM_ART", false) == true) { buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text); buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info); buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout); buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryInfoText.setPaintFlags( buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryMainText.setPaintFlags( buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setText(R.string.jams_is_caching_artwork); initScanProcess(0); } else if ((mApp.getSharedPreferences().getBoolean("REBUILD_LIBRARY", false) == true) || (scanFrequency == 0 && mApp.isScanFinished() == false) || (scanFrequency == 1 && mApp.isScanFinished() == false && updatedStartCount % 3 == 0) || (scanFrequency == 2 && mApp.isScanFinished() == false && updatedStartCount % 5 == 0) || (scanFrequency == 3 && mApp.isScanFinished() == false && updatedStartCount % 10 == 0) || (scanFrequency == 4 && mApp.isScanFinished() == false && updatedStartCount % 20 == 0)) { buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text); buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info); buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout); buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryInfoText.setPaintFlags( buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryMainText.setPaintFlags( buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); initScanProcess(1); } else { //Check if this activity was called from Settings. if (getIntent().hasExtra("UPGRADE")) { if (getIntent().getExtras().getBoolean("UPGRADE") == true) { mExplicitShowTrialFragment = true; } else { mExplicitShowTrialFragment = false; } } //initInAppBilling(); launchMainActivity(); } //Fire away a report to Google Analytics. try { if (mApp.isGoogleAnalyticsEnabled() == true) { EasyTracker easyTracker = EasyTracker.getInstance(this); easyTracker.send(MapBuilder.createEvent("Jelly startup.", // Event category (required) "User started Jelly.", // Event action (required) "User started Jelly.", // Event label null) // Event value .build()); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.mobicage.rogerthat.plugins.messaging.ServiceMessageDetailActivity.java
protected void updateMessageDetail(final boolean isUpdate) { T.UI();/*from w w w . j a v a2 s . c om*/ // Set sender avatar ImageView avatarImage = (ImageView) findViewById(R.id.avatar); String sender = mCurrentMessage.sender; setAvatar(avatarImage, sender); // Set sender name TextView senderView = (TextView) findViewById(R.id.sender); final String senderName = mFriendsPlugin.getName(sender); senderView.setText(senderName == null ? sender : senderName); // Set timestamp TextView timestampView = (TextView) findViewById(R.id.timestamp); timestampView.setText(TimeUtils.getDayTimeStr(this, mCurrentMessage.timestamp * 1000)); // Set clickable region on top to go to friends detail final RelativeLayout messageHeader = (RelativeLayout) findViewById(R.id.message_header); messageHeader.setOnClickListener(getFriendDetailOnClickListener(mCurrentMessage.sender)); messageHeader.setVisibility(View.VISIBLE); // Set message TextView messageView = (TextView) findViewById(R.id.message); WebView web = (WebView) findViewById(R.id.webview); FrameLayout flay = (FrameLayout) findViewById(R.id.message_details); Resources resources = getResources(); flay.setBackgroundColor(resources.getColor(R.color.mc_background)); boolean showBranded = false; int darkSchemeTextColor = resources.getColor(android.R.color.primary_text_dark); int lightSchemeTextColor = resources.getColor(android.R.color.primary_text_light); senderView.setTextColor(lightSchemeTextColor); timestampView.setTextColor(lightSchemeTextColor); BrandingResult br = null; if (!TextUtils.isEmptyOrWhitespace(mCurrentMessage.branding)) { boolean brandingAvailable = false; try { brandingAvailable = mMessagingPlugin.getBrandingMgr().isBrandingAvailable(mCurrentMessage.branding); } catch (BrandingFailureException e1) { L.d(e1); } try { if (brandingAvailable) { br = mMessagingPlugin.getBrandingMgr().prepareBranding(mCurrentMessage); WebSettings settings = web.getSettings(); settings.setJavaScriptEnabled(false); settings.setBlockNetworkImage(false); web.loadUrl("file://" + br.file.getAbsolutePath()); web.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); if (br.color != null) { flay.setBackgroundColor(br.color); } if (!br.showHeader) { messageHeader.setVisibility(View.GONE); MarginLayoutParams mlp = (MarginLayoutParams) web.getLayoutParams(); mlp.setMargins(0, 0, 0, mlp.bottomMargin); } else if (br.scheme == ColorScheme.dark) { senderView.setTextColor(darkSchemeTextColor); timestampView.setTextColor(darkSchemeTextColor); } showBranded = true; } else { mMessagingPlugin.getBrandingMgr().queueGenericBranding(mCurrentMessage.branding); } } catch (BrandingFailureException e) { L.bug("Could not display message with branding: branding is available, but prepareBranding failed", e); } } if (showBranded) { web.setVisibility(View.VISIBLE); messageView.setVisibility(View.GONE); } else { web.setVisibility(View.GONE); messageView.setVisibility(View.VISIBLE); messageView.setText(mCurrentMessage.message); } // Add list of members who did not ack yet FlowLayout memberSummary = (FlowLayout) findViewById(R.id.member_summary); memberSummary.removeAllViews(); SortedSet<MemberStatusTO> memberSummarySet = new TreeSet<MemberStatusTO>(getMemberstatusComparator()); for (MemberStatusTO ms : mCurrentMessage.members) { if ((ms.status & MessagingPlugin.STATUS_ACKED) != MessagingPlugin.STATUS_ACKED && !ms.member.equals(mCurrentMessage.sender)) { memberSummarySet.add(ms); } } FlowLayout.LayoutParams flowLP = new FlowLayout.LayoutParams(2, 0); for (MemberStatusTO ms : memberSummarySet) { FrameLayout fl = new FrameLayout(this); fl.setLayoutParams(flowLP); memberSummary.addView(fl); fl.addView(createParticipantView(ms)); } memberSummary.setVisibility(memberSummarySet.size() < 2 ? View.GONE : View.VISIBLE); // Add members statuses final LinearLayout members = (LinearLayout) findViewById(R.id.members); members.removeAllViews(); final String myEmail = mService.getIdentityStore().getIdentity().getEmail(); boolean isMember = false; mSomebodyAnswered = false; for (MemberStatusTO ms : mCurrentMessage.members) { boolean showMember = true; View view = getLayoutInflater().inflate(R.layout.message_member_detail, null); // Set receiver avatar RelativeLayout rl = (RelativeLayout) view.findViewById(R.id.avatar); rl.addView(createParticipantView(ms)); // Set receiver name TextView receiverView = (TextView) view.findViewById(R.id.receiver); final String memberName = mFriendsPlugin.getName(ms.member); receiverView.setText(memberName == null ? sender : memberName); // Set received timestamp TextView receivedView = (TextView) view.findViewById(R.id.received_timestamp); if ((ms.status & MessagingPlugin.STATUS_RECEIVED) == MessagingPlugin.STATUS_RECEIVED) { final String humanTime = TimeUtils.getDayTimeStr(this, ms.received_timestamp * 1000); if (ms.member.equals(mCurrentMessage.sender)) receivedView.setText(getString(R.string.sent_at, humanTime)); else receivedView.setText(getString(R.string.received_at, humanTime)); } else { receivedView.setText(R.string.not_yet_received); } // Set replied timestamp TextView repliedView = (TextView) view.findViewById(R.id.acked_timestamp); if ((ms.status & MessagingPlugin.STATUS_ACKED) == MessagingPlugin.STATUS_ACKED) { mSomebodyAnswered = true; String acked_timestamp = TimeUtils.getDayTimeStr(this, ms.acked_timestamp * 1000); if (ms.button_id != null) { ButtonTO button = null; for (ButtonTO b : mCurrentMessage.buttons) { if (b.id.equals(ms.button_id)) { button = b; break; } } if (button == null) { repliedView.setText(getString(R.string.dismissed_at, acked_timestamp)); // Do not show sender as member if he hasn't clicked a // button showMember = !ms.member.equals(mCurrentMessage.sender); } else { repliedView.setText(getString(R.string.replied_at, button.caption, acked_timestamp)); } } else { if (ms.custom_reply == null) { // Do not show sender as member if he hasn't clicked a // button showMember = !ms.member.equals(mCurrentMessage.sender); repliedView.setText(getString(R.string.dismissed_at, acked_timestamp)); } else repliedView.setText(getString(R.string.replied_at, ms.custom_reply, acked_timestamp)); } } else { repliedView.setText(R.string.not_yet_replied); showMember = !ms.member.equals(mCurrentMessage.sender); } if (br != null && br.scheme == ColorScheme.dark) { receiverView.setTextColor(darkSchemeTextColor); receivedView.setTextColor(darkSchemeTextColor); repliedView.setTextColor(darkSchemeTextColor); } else { receiverView.setTextColor(lightSchemeTextColor); receivedView.setTextColor(lightSchemeTextColor); repliedView.setTextColor(lightSchemeTextColor); } if (showMember) members.addView(view); isMember |= ms.member.equals(myEmail); } boolean isLocked = (mCurrentMessage.flags & MessagingPlugin.FLAG_LOCKED) == MessagingPlugin.FLAG_LOCKED; boolean canEdit = isMember && !isLocked; // Add attachments LinearLayout attachmentLayout = (LinearLayout) findViewById(R.id.attachment_layout); attachmentLayout.removeAllViews(); if (mCurrentMessage.attachments.length > 0) { attachmentLayout.setVisibility(View.VISIBLE); for (final AttachmentTO attachment : mCurrentMessage.attachments) { View v = getLayoutInflater().inflate(R.layout.attachment_item, null); ImageView attachment_image = (ImageView) v.findViewById(R.id.attachment_image); if (AttachmentViewerActivity.CONTENT_TYPE_JPEG.equalsIgnoreCase(attachment.content_type) || AttachmentViewerActivity.CONTENT_TYPE_PNG.equalsIgnoreCase(attachment.content_type)) { attachment_image.setImageResource(R.drawable.attachment_img); } else if (AttachmentViewerActivity.CONTENT_TYPE_PDF.equalsIgnoreCase(attachment.content_type)) { attachment_image.setImageResource(R.drawable.attachment_pdf); } else if (AttachmentViewerActivity.CONTENT_TYPE_VIDEO_MP4 .equalsIgnoreCase(attachment.content_type)) { attachment_image.setImageResource(R.drawable.attachment_video); } else { attachment_image.setImageResource(R.drawable.attachment_unknown); L.d("attachment.content_type not known: " + attachment.content_type); } TextView attachment_text = (TextView) v.findViewById(R.id.attachment_text); attachment_text.setText(attachment.name); v.setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { String downloadUrlHash = mMessagingPlugin .attachmentDownloadUrlHash(attachment.download_url); File attachmentsDir; try { attachmentsDir = mMessagingPlugin.attachmentsDir(mCurrentMessage.getThreadKey(), null); } catch (IOException e) { L.d("Unable to create attachment directory", e); UIUtils.showAlertDialog(ServiceMessageDetailActivity.this, "", R.string.unable_to_read_write_sd_card); return; } boolean attachmentAvailable = mMessagingPlugin.attachmentExists(attachmentsDir, downloadUrlHash); if (!attachmentAvailable) { try { attachmentsDir = mMessagingPlugin.attachmentsDir(mCurrentMessage.getThreadKey(), mCurrentMessage.key); } catch (IOException e) { L.d("Unable to create attachment directory", e); UIUtils.showAlertDialog(ServiceMessageDetailActivity.this, "", R.string.unable_to_read_write_sd_card); return; } attachmentAvailable = mMessagingPlugin.attachmentExists(attachmentsDir, downloadUrlHash); } if (!mService.getNetworkConnectivityManager().isConnected() && !attachmentAvailable) { AlertDialog.Builder builder = new AlertDialog.Builder( ServiceMessageDetailActivity.this); builder.setMessage(R.string.no_internet_connection_try_again); builder.setPositiveButton(R.string.rogerthat, null); AlertDialog dialog = builder.create(); dialog.show(); return; } if (IOUtils.shouldCheckExternalStorageAvailable()) { String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state)) { // Its all oke } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { if (!attachmentAvailable) { L.d("Unable to write to sd-card"); UIUtils.showAlertDialog(ServiceMessageDetailActivity.this, "", R.string.unable_to_read_write_sd_card); return; } } else { L.d("Unable to read or write to sd-card"); UIUtils.showAlertDialog(ServiceMessageDetailActivity.this, "", R.string.unable_to_read_write_sd_card); return; } } L.d("attachment.content_type: " + attachment.content_type); L.d("attachment.download_url: " + attachment.download_url); L.d("attachment.name: " + attachment.name); L.d("attachment.size: " + attachment.size); if (AttachmentViewerActivity.supportsContentType(attachment.content_type)) { Intent i = new Intent(ServiceMessageDetailActivity.this, AttachmentViewerActivity.class); i.putExtra("thread_key", mCurrentMessage.getThreadKey()); i.putExtra("message", mCurrentMessage.key); i.putExtra("content_type", attachment.content_type); i.putExtra("download_url", attachment.download_url); i.putExtra("name", attachment.name); i.putExtra("download_url_hash", downloadUrlHash); startActivity(i); } else { AlertDialog.Builder builder = new AlertDialog.Builder( ServiceMessageDetailActivity.this); builder.setMessage(getString(R.string.attachment_can_not_be_displayed_in_your_version, getString(R.string.app_name))); builder.setPositiveButton(R.string.rogerthat, null); AlertDialog dialog = builder.create(); dialog.show(); } } }); attachmentLayout.addView(v); } } else { attachmentLayout.setVisibility(View.GONE); } LinearLayout widgetLayout = (LinearLayout) findViewById(R.id.widget_layout); if (mCurrentMessage.form == null) { widgetLayout.setVisibility(View.GONE); } else { widgetLayout.setVisibility(View.VISIBLE); widgetLayout.setEnabled(canEdit); displayWidget(widgetLayout, br); } // Add buttons TableLayout tableLayout = (TableLayout) findViewById(R.id.buttons); tableLayout.removeAllViews(); for (final ButtonTO button : mCurrentMessage.buttons) { addButton(senderName, myEmail, mSomebodyAnswered, canEdit, tableLayout, button); } if (mCurrentMessage.form == null && (mCurrentMessage.flags & MessagingPlugin.FLAG_ALLOW_DISMISS) == MessagingPlugin.FLAG_ALLOW_DISMISS) { ButtonTO button = new ButtonTO(); button.caption = "Roger that!"; addButton(senderName, myEmail, mSomebodyAnswered, canEdit, tableLayout, button); } if (mCurrentMessage.broadcast_type != null) { L.d("Show broadcast spam control"); final RelativeLayout broadcastSpamControl = (RelativeLayout) findViewById(R.id.broadcast_spam_control); View broadcastSpamControlBorder = findViewById(R.id.broadcast_spam_control_border); final View broadcastSpamControlDivider = findViewById(R.id.broadcast_spam_control_divider); final LinearLayout broadcastSpamControlTextContainer = (LinearLayout) findViewById( R.id.broadcast_spam_control_text_container); TextView broadcastSpamControlText = (TextView) findViewById(R.id.broadcast_spam_control_text); final LinearLayout broadcastSpamControlSettingsContainer = (LinearLayout) findViewById( R.id.broadcast_spam_control_settings_container); TextView broadcastSpamControlSettingsText = (TextView) findViewById( R.id.broadcast_spam_control_settings_text); TextView broadcastSpamControlIcon = (TextView) findViewById(R.id.broadcast_spam_control_icon); broadcastSpamControlIcon.setTypeface(mFontAwesomeTypeFace); broadcastSpamControlIcon.setText(R.string.fa_bell); final FriendBroadcastInfo fbi = mFriendsPlugin.getFriendBroadcastFlowForMfr(mCurrentMessage.sender); if (fbi == null) { L.bug("BroadcastData was null for: " + mCurrentMessage.sender); collapseDetails(DETAIL_SECTIONS); return; } broadcastSpamControl.setVisibility(View.VISIBLE); broadcastSpamControlSettingsContainer.setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { L.d("goto broadcast settings"); PressMenuIconRequestTO request = new PressMenuIconRequestTO(); request.coords = fbi.coords; request.static_flow_hash = fbi.staticFlowHash; request.hashed_tag = fbi.hashedTag; request.generation = fbi.generation; request.service = mCurrentMessage.sender; mContext = "MENU_" + UUID.randomUUID().toString(); request.context = mContext; request.timestamp = System.currentTimeMillis() / 1000; showTransmitting(null); Map<String, Object> userInput = new HashMap<String, Object>(); userInput.put("request", request.toJSONMap()); userInput.put("func", "com.mobicage.api.services.pressMenuItem"); MessageFlowRun mfr = new MessageFlowRun(); mfr.staticFlowHash = fbi.staticFlowHash; try { JsMfr.executeMfr(mfr, userInput, mService, true); } catch (EmptyStaticFlowException ex) { completeTransmit(null); AlertDialog.Builder builder = new AlertDialog.Builder(ServiceMessageDetailActivity.this); builder.setMessage(ex.getMessage()); builder.setPositiveButton(R.string.rogerthat, null); AlertDialog dialog = builder.create(); dialog.show(); return; } } }); UIUtils.showHint(this, mService, HINT_BROADCAST, R.string.hint_broadcast, mCurrentMessage.broadcast_type, mFriendsPlugin.getName(mCurrentMessage.sender)); broadcastSpamControlText .setText(getString(R.string.broadcast_subscribed_to, mCurrentMessage.broadcast_type)); broadcastSpamControlSettingsText.setText(fbi.label); int ligthAlpha = 180; int darkAlpha = 70; int alpha = ligthAlpha; if (br != null && br.scheme == ColorScheme.dark) { broadcastSpamControlIcon.setTextColor(getResources().getColor(android.R.color.black)); broadcastSpamControlBorder.setBackgroundColor(darkSchemeTextColor); broadcastSpamControlDivider.setBackgroundColor(darkSchemeTextColor); activity.setBackgroundColor(darkSchemeTextColor); broadcastSpamControlText.setTextColor(lightSchemeTextColor); broadcastSpamControlSettingsText.setTextColor(lightSchemeTextColor); int alpacolor = Color.argb(darkAlpha, Color.red(lightSchemeTextColor), Color.green(lightSchemeTextColor), Color.blue(lightSchemeTextColor)); broadcastSpamControl.setBackgroundColor(alpacolor); alpha = darkAlpha; } else { broadcastSpamControlIcon.setTextColor(getResources().getColor(android.R.color.white)); broadcastSpamControlBorder.setBackgroundColor(lightSchemeTextColor); broadcastSpamControlDivider.setBackgroundColor(lightSchemeTextColor); activity.setBackgroundColor(lightSchemeTextColor); broadcastSpamControlText.setTextColor(darkSchemeTextColor); broadcastSpamControlSettingsText.setTextColor(darkSchemeTextColor); int alpacolor = Color.argb(darkAlpha, Color.red(darkSchemeTextColor), Color.green(darkSchemeTextColor), Color.blue(darkSchemeTextColor)); broadcastSpamControl.setBackgroundColor(alpacolor); } if (br != null && br.color != null) { int alphaColor = Color.argb(alpha, Color.red(br.color), Color.green(br.color), Color.blue(br.color)); broadcastSpamControl.setBackgroundColor(alphaColor); } mService.postOnUIHandler(new SafeRunnable() { @Override protected void safeRun() throws Exception { int maxHeight = broadcastSpamControl.getHeight(); broadcastSpamControlDivider.getLayoutParams().height = maxHeight; broadcastSpamControlDivider.requestLayout(); broadcastSpamControlSettingsContainer.getLayoutParams().height = maxHeight; broadcastSpamControlSettingsContainer.requestLayout(); broadcastSpamControlTextContainer.getLayoutParams().height = maxHeight; broadcastSpamControlTextContainer.requestLayout(); int broadcastSpamControlWidth = broadcastSpamControl.getWidth(); android.view.ViewGroup.LayoutParams lp = broadcastSpamControlSettingsContainer .getLayoutParams(); lp.width = broadcastSpamControlWidth / 4; broadcastSpamControlSettingsContainer.setLayoutParams(lp); } }); } if (!isUpdate) collapseDetails(DETAIL_SECTIONS); }