Android Open Source - contactphotosync Select Account Activity






From Project

Back to project page contactphotosync.

License

The source code is released under:

GNU General Public License

If you think the Android project contactphotosync 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

/**
 * SelectAccountActivity.java - Allows user to choose a Google account.
 * //from  w ww .  j  a va2 s . co m
 * Copyright (C) 2012 Mansour <mansour@oxplot.com>
 * All rights reserved.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see
 * <http://www.gnu.org/licenses/>.
 */

package com.oxplot.contactphotosync;

import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class SelectAccountActivity extends Activity {

  private static final String ACCOUNT_TYPE = "com.google";
  private ListView list;
  private ArrayAdapter<String> adapter;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTitle(getResources().getString(R.string.title_activity_select_account));

    // Let's see if the user is willing to give us root permission at the very
    // start
    Util.runRoot("");

    setContentView(R.layout.activity_select_account);
    getActionBar().setHomeButtonEnabled(false);
    list = (ListView) findViewById(R.id.list);
    adapter = new ArrayAdapter<String>(this, R.layout.account_row, R.id.row);
    list.setAdapter(adapter);

    list.setEmptyView(findViewById(R.id.empty));

    list.setOnItemClickListener(new OnItemClickListener() {

      @Override
      public void onItemClick(AdapterView<?> a, View view, int curViewId,
          long id) {
        String account = adapter.getItem((int) id);
        Intent intent = new Intent(SelectAccountActivity.this,
            AssignContactPhotoActivity.class);
        intent.putExtra("account", account);
        startActivity(intent);
      }
    });
  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_select_account, menu);
    return true;
  }

  @Override
  protected void onResume() {
    super.onResume();
    AccountManager manager = AccountManager.get(this);
    adapter.clear();
    for (Account account : manager.getAccountsByType(ACCOUNT_TYPE))
      adapter.add(account.name);
    adapter.notifyDataSetChanged();
  }

}




Java Source Code List

com.oxplot.contactphotosync.AssignContactPhotoActivity.java
com.oxplot.contactphotosync.ConcatInputStreams.java
com.oxplot.contactphotosync.CropPhotoActivity.java
com.oxplot.contactphotosync.CropView.java
com.oxplot.contactphotosync.PhotoProvider.java
com.oxplot.contactphotosync.PicasawebService.java
com.oxplot.contactphotosync.SelectAccountActivity.java
com.oxplot.contactphotosync.SyncAdapter.java
com.oxplot.contactphotosync.SyncService.java
com.oxplot.contactphotosync.Util.java