Search in sources :

Example 31 with ActionBar

use of android.app.ActionBar in project GTFSOffline by wbrenna.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    }
    mProgress = (ProgressBar) findViewById(R.id.progress);
    // read in the preferences
    mPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    Set<String> emptyString = new HashSet<String>();
    emptyString.clear();
    Set<String> initial_preferences = mPrefs.getStringSet(getString(R.string.pref_dbs), emptyString);
    mDBListPrefsOld = initial_preferences;
    // this is the list of currently checked databases
    String[] tmpDBActive = initial_preferences.toArray(new String[initial_preferences.size()]);
    // we have to be careful to exclude databases that aren't in our directory
    dbHelper = new DatabaseHelper(this);
    dbHelper.gatherFiles();
    mDBList = dbHelper.GetListofDB();
    List<String> workingDBList = new ArrayList<String>();
    for (int i = 0; i < tmpDBActive.length; i++) {
        if (mDBList.contains(tmpDBActive[i])) {
            workingDBList.add(tmpDBActive[i]);
        } else {
            initial_preferences.remove(tmpDBActive[i]);
        }
    }
    if (workingDBList.size() == 0) {
        mDBActive = null;
    } else {
        mDBActive = workingDBList.toArray(new String[workingDBList.size()]);
    }
    Editor prefsDBEditor = mPrefs.edit();
    prefsDBEditor.putStringSet(getString(R.string.pref_dbs), initial_preferences);
    prefsDBEditor.commit();
    // Set up the location management
    mLocationHelper = new LocationHelper(this);
    mLocation = mLocationHelper.startLocationManager();
    // Define a listener that responds to location updates
    locationListener = new LocationListener() {

        @Override
        public void onLocationChanged(Location location) {
            if (mLocationHelper.isBetterLocation(location, mLocation)) {
                mLocation = location;
                if (mLocation != null) {
                    // new ProcessBusStops().execute();
                    mSectionsPagerAdapter.notifyDataSetChanged();
                } else {
                    Toast.makeText(getBaseContext(), R.string.last_location_fix, Toast.LENGTH_LONG).show();
                // Log.e(TAG, "No more location fixes ");
                }
            }
        }

        @Override
        public void onStatusChanged(String provider, int status, Bundle extras) {
        }

        @Override
        public void onProviderEnabled(String provider) {
        }

        @Override
        public void onProviderDisabled(String provider) {
        }
    };
    // TODO: eventually add automated downloading of databases...
    // Create the adapter that will return a fragment for each of the
    // primary sections of the app.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    });
    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
        actionBar.addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
}
Also used : Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) ViewPager(android.support.v4.view.ViewPager) LocationListener(android.location.LocationListener) Editor(android.content.SharedPreferences.Editor) ActionBar(android.app.ActionBar) HashSet(java.util.HashSet) Location(android.location.Location)

Example 32 with ActionBar

use of android.app.ActionBar in project android_packages_apps_Settings by crdroidandroid.

the class RunningServices method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    ActionBar actionBar = getActivity().getActionBar();
    switch(item.getItemId()) {
        case SHOW_RUNNING_SERVICES:
            mRunningProcessesView.mAdapter.setShowBackground(false);
            actionBar.setTitle(R.string.runningservices_settings_title);
            break;
        case SHOW_BACKGROUND_PROCESSES:
            mRunningProcessesView.mAdapter.setShowBackground(true);
            actionBar.setTitle(R.string.background_processes_settings_title);
            break;
        default:
            return false;
    }
    updateOptionsMenu();
    return true;
}
Also used : ActionBar(android.app.ActionBar)

Example 33 with ActionBar

use of android.app.ActionBar in project android_packages_apps_Settings by crdroidandroid.

the class EntityHeaderControllerTest method styleActionBar_setElevationAndBackground.

@Test
public void styleActionBar_setElevationAndBackground() {
    final ActionBar actionBar = mActivity.getActionBar();
    mController = EntityHeaderController.newInstance(mActivity, mFragment, null);
    mController.styleActionBar(mActivity);
    verify(actionBar).setElevation(0);
    // Enforce a color drawable as background here, as image based drawables might not be
    // wide enough to cover entire action bar.
    verify(actionBar).setBackgroundDrawable(any(ColorDrawable.class));
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) ActionBar(android.app.ActionBar) Test(org.junit.Test)

Example 34 with ActionBar

use of android.app.ActionBar in project android_packages_apps_Settings by SudaMod.

the class EntityHeaderController method styleActionBar.

public EntityHeaderController styleActionBar(Activity activity) {
    if (activity == null) {
        Log.w(TAG, "No activity, cannot style actionbar.");
        return this;
    }
    final ActionBar actionBar = activity.getActionBar();
    if (actionBar == null) {
        Log.w(TAG, "No actionbar, cannot style actionbar.");
        return this;
    }
    actionBar.setBackgroundDrawable(new ColorDrawable(Utils.getColorAttr(activity, android.R.attr.colorSecondary)));
    actionBar.setElevation(0);
    if (mRecyclerView != null && mLifecycle != null) {
        ActionBarShadowController.attachToRecyclerView(mActivity, mLifecycle, mRecyclerView);
    }
    return this;
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) ActionBar(android.app.ActionBar)

Example 35 with ActionBar

use of android.app.ActionBar in project android_packages_apps_Settings by SudaMod.

the class UserDictionarySettings method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Show the language as a subtitle of the action bar
    final ActionBar actionBar = getActivity().getActionBar();
    if (actionBar != null) {
        actionBar.setTitle(R.string.user_dict_settings_title);
        actionBar.setSubtitle(UserDictionarySettingsUtils.getLocaleDisplayName(getActivity(), mLocale));
    }
    return inflater.inflate(com.android.internal.R.layout.preference_list_fragment, container, false);
}
Also used : ActionBar(android.app.ActionBar)

Aggregations

ActionBar (android.app.ActionBar)265 View (android.view.View)58 Intent (android.content.Intent)35 TextView (android.widget.TextView)21 ColorDrawable (android.graphics.drawable.ColorDrawable)20 OnClickListener (android.view.View.OnClickListener)14 AdapterView (android.widget.AdapterView)14 ListView (android.widget.ListView)12 Bundle (android.os.Bundle)10 Test (org.junit.Test)10 SharedPreferences (android.content.SharedPreferences)9 Uri (android.net.Uri)9 Button (android.widget.Button)9 AlertDialog (android.app.AlertDialog)8 DialogInterface (android.content.DialogInterface)8 ViewPager (android.support.v4.view.ViewPager)8 SpannableString (android.text.SpannableString)8 ComponentName (android.content.ComponentName)7 ArrayAdapter (android.widget.ArrayAdapter)7 FrameLayout (android.widget.FrameLayout)7