Android Open Source - PhoneProfiles_Eclipse Shortcut Creator Activity






From Project

Back to project page PhoneProfiles_Eclipse.

License

The source code is released under:

Apache License

If you think the Android project PhoneProfiles_Eclipse listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package sk.henrichg.phoneprofiles;
/* ww w.  j av a2s. com*/
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.util.TypedValue;
import android.view.Display;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;

public class ShortcutCreatorActivity extends ActionBarActivity {

  private DataWrapper dataWrapper;
  
  private float popupWidth;
  private float popupMaxHeight;
  private float popupHeight;
  private float actionBarHeight;

  
  @SuppressWarnings("deprecation")
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    GUIData.setTheme(this, true);
    GUIData.setLanguage(getBaseContext());

    dataWrapper = new DataWrapper(getBaseContext(), true, false, 0);

  // set window dimensions ----------------------------------------------------------
    
    Display display = getWindowManager().getDefaultDisplay();
    
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND, WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    LayoutParams params = getWindow().getAttributes();
    params.alpha = 1.0f;
    params.dimAmount = 0.5f;
    getWindow().setAttributes(params);
    
    // display dimensions
    popupWidth = display.getWidth();
    popupMaxHeight = display.getHeight();
    popupHeight = 0;
    actionBarHeight = 0;

    // action bar height
    TypedValue tv = new TypedValue();
    if (getTheme().resolveAttribute(android.support.v7.appcompat.R.attr.actionBarSize, tv, true))
          actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data,getResources().getDisplayMetrics());
    
    // set max. dimensions for display orientation
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
    {
      //popupWidth = Math.round(popupWidth / 100f * 50f);
      //popupMaxHeight = Math.round(popupMaxHeight / 100f * 90f);
      popupWidth = popupWidth / 100f * 50f;
      popupMaxHeight = popupMaxHeight / 100f * 90f;
    }
    else
    {
      //popupWidth = Math.round(popupWidth / 100f * 70f);
      //popupMaxHeight = Math.round(popupMaxHeight / 100f * 90f);
      popupWidth = popupWidth / 100f * 70f;
      popupMaxHeight = popupMaxHeight / 100f * 90f;
    }

    // add action bar height
    popupHeight = popupHeight + actionBarHeight;
    
    final float scale = getResources().getDisplayMetrics().density;
    
    // add list items height
    int profileCount = dataWrapper.getDatabaseHandler().getProfilesCount();
    popupHeight = popupHeight + (50f * scale * profileCount); // item
    popupHeight = popupHeight + (5f * scale * (profileCount-1)); // divider

    popupHeight = popupHeight + (20f * scale); // listview padding
    
    if (popupHeight > popupMaxHeight)
      popupHeight = popupMaxHeight;
  
    // set popup window dimensions
    getWindow().setLayout((int) (popupWidth + 0.5f), (int) (popupHeight + 0.5f));
    
  //-----------------------------------------------------------------------------------

    setContentView(R.layout.activity_shortcut_creator);

    getSupportActionBar().setTitle(R.string.title_activity_shortcut_creator);
        
    //databaseHandler = new DatabaseHandler(this);
    
  }
  
  @Override
  protected void onStart()
  {
    super.onStart();
  }
  
  @Override
  protected void onDestroy()
  {
  //  Debug.stopMethodTracing();
    super.onDestroy();

    dataWrapper.invalidateDataWrapper();
    dataWrapper = null;
  }
  
  @Override
  public void onConfigurationChanged(Configuration newConfig)
  {
    super.onConfigurationChanged(newConfig);
    
    getBaseContext().getResources().updateConfiguration(newConfig, getBaseContext().getResources().getDisplayMetrics());
    GUIData.reloadActivity(this, false);
  }
  
}




Java Source Code List

sk.henrichg.phoneprofiles.ActivateProfileActivity.java
sk.henrichg.phoneprofiles.ActivateProfileHelper.java
sk.henrichg.phoneprofiles.ActivateProfileListAdapter.java
sk.henrichg.phoneprofiles.ActivateProfileListFragment.java
sk.henrichg.phoneprofiles.ApplicationsCache.java
sk.henrichg.phoneprofiles.ApplicationsPreferenceAdapter.java
sk.henrichg.phoneprofiles.ApplicationsPreferenceDialog.java
sk.henrichg.phoneprofiles.ApplicationsPreference.java
sk.henrichg.phoneprofiles.BackgroundActivateProfileActivity.java
sk.henrichg.phoneprofiles.BitmapManipulator.java
sk.henrichg.phoneprofiles.BootUpReceiver.java
sk.henrichg.phoneprofiles.BrightnessDialogPreference.java
sk.henrichg.phoneprofiles.BrightnessView.java
sk.henrichg.phoneprofiles.DashClockBroadcastReceiver.java
sk.henrichg.phoneprofiles.DataWrapper.java
sk.henrichg.phoneprofiles.DatabaseHandler.java
sk.henrichg.phoneprofiles.EditorProfileListAdapter.java
sk.henrichg.phoneprofiles.EditorProfileListFragment.java
sk.henrichg.phoneprofiles.EditorProfilesActivity.java
sk.henrichg.phoneprofiles.ExecuteRadioProfilePrefsService.java
sk.henrichg.phoneprofiles.ExecuteVolumeProfilePrefsService.java
sk.henrichg.phoneprofiles.FirstStartService.java
sk.henrichg.phoneprofiles.GUIData.java
sk.henrichg.phoneprofiles.GlobalData.java
sk.henrichg.phoneprofiles.IconWidgetProvider.java
sk.henrichg.phoneprofiles.ImageViewPreferenceAdapter.java
sk.henrichg.phoneprofiles.ImageViewPreferenceDialog.java
sk.henrichg.phoneprofiles.ImageViewPreference.java
sk.henrichg.phoneprofiles.KeyguardService.java
sk.henrichg.phoneprofiles.Keyguard.java
sk.henrichg.phoneprofiles.LocaleChangedReceiver.java
sk.henrichg.phoneprofiles.NumberPickerPreference.java
sk.henrichg.phoneprofiles.OneRowWidgetProvider.java
sk.henrichg.phoneprofiles.PackageReplacedReceiver.java
sk.henrichg.phoneprofiles.PhoneCallBroadcastReceiver.java
sk.henrichg.phoneprofiles.PhoneCallReceiver.java
sk.henrichg.phoneprofiles.PhoneProfilesDashClockExtension.java
sk.henrichg.phoneprofiles.PhoneProfilesHelper.java
sk.henrichg.phoneprofiles.PhoneProfilesPreferencesActivity.java
sk.henrichg.phoneprofiles.PhoneProfilesPreferencesFragment.java
sk.henrichg.phoneprofiles.ProfileDurationAlarmBroadcastReceiver.java
sk.henrichg.phoneprofiles.ProfileListWidgetFactory.java
sk.henrichg.phoneprofiles.ProfileListWidgetProvider.java
sk.henrichg.phoneprofiles.ProfileListWidgetService.java
sk.henrichg.phoneprofiles.ProfilePreferenceAdapter.java
sk.henrichg.phoneprofiles.ProfilePreferenceDialog.java
sk.henrichg.phoneprofiles.ProfilePreference.java
sk.henrichg.phoneprofiles.ProfilePreferencesFragmentActivity.java
sk.henrichg.phoneprofiles.ProfilePreferencesFragment.java
sk.henrichg.phoneprofiles.ProfilePreferencesIndicator.java
sk.henrichg.phoneprofiles.Profile.java
sk.henrichg.phoneprofiles.ReceiversService.java
sk.henrichg.phoneprofiles.RefreshGUIBroadcastReceiver.java
sk.henrichg.phoneprofiles.RemoteExportDataActivity.java
sk.henrichg.phoneprofiles.RemoveBrightnessViewBroadcastReceiver.java
sk.henrichg.phoneprofiles.ScreenOnOffBroadcastReceiver.java
sk.henrichg.phoneprofiles.ShortcutCreatorActivity.java
sk.henrichg.phoneprofiles.ShortcutCreatorListFragment.java
sk.henrichg.phoneprofiles.ShortcutProfileListAdapter.java
sk.henrichg.phoneprofiles.UpgradePPHelperActivity.java
sk.henrichg.phoneprofiles.VolumeDialogPreference.java