Example #1
1
 // 菜单响应
 public boolean onOptionsItemSelected(MenuItem item) {
   super.onOptionsItemSelected(item);
   switch (item.getItemId()) {
     case 0:
       ActivityManager.getInstance().exit();
   }
   return true;
 }
Example #2
0
  /** Test cache management */
  public void testCacheManagement() throws ActivityStorageException {
    Identity rootIdentity =
        identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME, "root");
    Identity johnIdentity =
        identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME, "john");
    // Identity maryIdentity =
    // identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME,
    // "mary");
    // Identity demoIdentity =
    // identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME,
    // "demo");

    Profile rootProfile = rootIdentity.getProfile();
    Profile johnProfile = johnIdentity.getProfile();
    // Profile maryProfile = maryIdentity.getProfile();
    // Profile demoProfile = demoIdentity.getProfile();

    final String newFirstName = "New First Name";

    rootProfile.setProperty(Profile.FIRST_NAME, newFirstName);
    identityManager.saveProfile(rootProfile);
    Identity gotRootIdentity =
        identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME, "root", true);
    assertNotNull("gotRootIdentity.getId() must not be null", gotRootIdentity.getId());
    assertEquals(
        "gotRootIdentity.getProfile().getProperty(Profile.FIRST_NAME) must be updated: "
            + newFirstName,
        newFirstName,
        gotRootIdentity.getProfile().getProperty(Profile.FIRST_NAME));

    try {
      identityManager.updateAvatar(johnProfile);
    } catch (Exception e1) {
      assert false : "can't update avatar" + e1;
    }

    Identity gotJohnIdentity =
        identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME, "john");
    tearDownIdentityList.add(johnIdentity);
    tearDownIdentityList.add(rootIdentity);
    // an activity for avatar created, clean it up here

    ActivityManager activityManager =
        (ActivityManager) getContainer().getComponentInstanceOfType(ActivityManager.class);

    end();
    begin();

    List<ExoSocialActivity> johnActivityList =
        activityManager.getActivities(gotJohnIdentity, 0, 10);
    assertEquals("johnActivityList.size() must be 1", 1, johnActivityList.size());
  }
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.menu_website:
       Uri uri = Uri.parse("http://moeapk.com/apk/" + app_package + ".html");
       Intent intent = new Intent(Intent.ACTION_VIEW, uri);
       startActivity(intent);
       break;
     case R.id.menu_clear_cache:
       memoryCache.clear();
       fileUtils.clearCache();
       Toast.makeText(
               getApplicationContext(), R.string.toast_clear_cache_finish, Toast.LENGTH_LONG)
           .show();
       break;
     case R.id.menu_about:
       Intent myintent = new Intent();
       myintent.setClass(ApkListActivity.this, AboutActivity.class);
       startActivity(myintent);
       break;
     case R.id.menu_exit:
       ActivityManager.getInstance().exit();
       break;
   }
   return true;
 }
Example #4
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_index);

    localinfo = new LocalInfo(this);

    // 活动管理器
    ActivityManager.getInstance().addActivity(IndexActivity.this);

    // 绑定列表样式
    index_listview = (ListView) findViewById(R.id.index_list);

    // 设定点击监听器
    index_listview.setOnItemClickListener(this);

    MoeApkSetEditor = this.getSharedPreferences(MoeApk_PREF_NAME, 2).edit();
    MoeApkSetReader = this.getSharedPreferences(MoeApk_PREF_NAME, 1);

    // 获取分类
    list_item = moeapk.App_Type;

    // 制造列表
    ThreadGetList();
    FirstStart();
    // 向API服务器报告一次运行了这个客户端
    moeapk.registerClient(DeviceId);
  }
  /** the entrance for the application */
  @Override
  public void onCreate() {
    // TODO Auto-generated method stub
    super.onCreate();
    context = this;

    // Baidu Push Service
    FrontiaApplication.initFrontiaApplication(context);

    mBaiduPushServer = new BaiduPush(BaiduPush.HTTP_METHOD_POST, SECRIT_KEY, API_KEY);

    // 不转换没有 @Expose 注解的字段
    mGson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();

    mSpUtil = new SharedPreferencesUtil(this, SP_FILE_NAME);
    mUserDB = new UserDB(this);
    mMsgDB = new MsgDB(this);
    mConvDB = new ConvDB(this);
    mUserList = mUserDB.getAll();
    mMediaPlayer = MediaPlayer.create(this, R.raw.office);
    mNotificationManager =
        (NotificationManager) getSystemService(android.content.Context.NOTIFICATION_SERVICE);

    loadUserBaseData();

    activityManager = ActivityManager.getActivityManager(this); // 实例化活动管理类
    dbOperation = new MailDB(this);
    UID_SET = dbOperation.loadUIDSet("inbox");

    //		// Start Notification Service
    //		startNotificationService();
  }
Example #6
0
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   ActivityManager.getAppManager().addActivity(this);
   if (!ApplicationUser.CheckLogin(PubUserActivity.this)) {
     Intent intent1 = new Intent(PubUserActivity.this, U_Login.class);
     startActivity(intent1);
   }
 }
Example #7
0
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
     if ((System.currentTimeMillis() - exitTime) > 2000) {
       Toast.makeText(getApplicationContext(), "再按一次退出程序", Toast.LENGTH_LONG).show();
       exitTime = System.currentTimeMillis();
     } else {
       ActivityManager.getInstance().exit();
     }
     return true;
   }
   return super.onKeyDown(keyCode, event);
 }
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_applist);

    // 活动管理器
    ActivityManager.getInstance().addActivity(ApkListActivity.this);

    setTitle(getResources().getString(R.string.title_choose_version));
    Log.i("DEBUG", "进入APK库");
    intent = getIntent();
    listview = (ListView) findViewById(R.id.AppListView);
    listview.setOnItemClickListener(this);
    app_package = intent.getStringExtra("app_package");
    ThreadGetList();
  }
  /*
   * The exit of the applictaion(non-Javadoc)
   *
   * @see android.app.Application#onTerminate()
   */
  @Override
  public void onTerminate() {
    // TODO Auto-generated method stub
    super.onTerminate();

    saveUserBaseData();

    // stop the main service
    Intent it = new Intent();
    it.setClass(this, MainService.class);
    stopService(it);

    // stop the notification service
    stopNotificationService();

    activityManager.exit();
  }
Example #10
0
  /** Test {@link IdentityManager#updateProfile(Profile)} */
  public void testUpdateProfile() throws Exception {
    Identity rootIdentity =
        identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME, "root");
    Profile profile = rootIdentity.getProfile();
    profile.setProperty(Profile.POSITION, "CEO");
    identityManager.updateProfile(profile);

    Identity identityUpdated =
        identityManager.getOrCreateIdentity(
            rootIdentity.getProviderId(), rootIdentity.getRemoteId(), false);
    assertEquals("CEO", identityUpdated.getProfile().getProperty(Profile.POSITION));

    end();
    begin();

    List<ExoSocialActivity> rootActivityList = activityManager.getActivities(rootIdentity);

    tearDownIdentityList.add(rootIdentity);
  }
Example #11
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.activity_register);

    // 退出时清除所有Activity
    ActivityManager.getInstance().addActivity(this);

    register_name = (EditText) findViewById(R.id.register_name);
    register_password = (EditText) findViewById(R.id.register_password);
    register_password_confirm = (EditText) findViewById(R.id.register_password_confirm);
    register_telephone = (EditText) findViewById(R.id.register_telephone);
    radioSex = (RadioGroup) findViewById(R.id.radio_sex);
    radio_male = (RadioButton) findViewById(R.id.radioButton_male);
    radio_female = (RadioButton) findViewById(R.id.radioButton_female);

    mRegisterFormView = findViewById(R.id.Register_ScrollView);
    mRegisterStatusView = findViewById(R.id.register_status);

    findViewById(R.id.register_confirm)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                attemptRegister();
              }
            });
    findViewById(R.id.register_cancel)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                Intent intent = new Intent(RegisterActivity.this, LoginActivity.class);
                startActivity(intent);
                RegisterActivity.this.finish();
              }
            });
    register_name.requestFocus();
  }
Example #12
0
  public void testGetIdentitiesByName() throws Exception {
    User user = userHandler.createUserInstance("alex");
    user.setFirstName("");
    user.setLastName("");
    user.setEmail("");
    userHandler.createUser(user, true);
    User found = userHandler.findUserByName("alex");
    assertNotNull(found);
    String providerId = OrganizationIdentityProvider.NAME;

    Identity identity = new Identity(providerId, "alex");
    identityManager.saveIdentity(identity);
    Profile profile = new Profile(identity);
    profile.setProperty(Profile.USERNAME, "alex");
    profile.setProperty(Profile.FIRST_NAME, "Mary");
    profile.setProperty(Profile.LAST_NAME, "Williams");
    profile.setProperty(Profile.FULL_NAME, "Mary " + "Williams");
    profile.setProperty(Profile.POSITION, "developer");
    profile.setProperty(Profile.GENDER, "female");
    identityManager.saveProfile(profile);
    identity.setProfile(profile);
    tearDownIdentityList.add(identity);

    ProfileFilter pf = new ProfileFilter();

    // Search by name full name
    pf.setName("Mary");
    ListAccess<Identity> idsListAccess =
        identityManager.getIdentitiesByProfileFilter(providerId, pf, false);
    assertEquals(1, idsListAccess.getSize());
    pf.setName("Williams");
    idsListAccess = identityManager.getIdentitiesByProfileFilter(providerId, pf, false);
    assertEquals(1, idsListAccess.getSize());
    pf.setName("Mary Williams");
    idsListAccess = identityManager.getIdentitiesByProfileFilter(providerId, pf, false);
    assertEquals(1, idsListAccess.getSize());

    // update profile name
    profile.setProperty(Profile.FIRST_NAME, "Mary-James");
    profile.setProperty(Profile.FULL_NAME, "Mary-James Williams");
    identityManager.updateProfile(profile);
    Identity alex =
        identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME, "alex", true);
    assertEquals("Mary-James Williams", alex.getProfile().getFullName());

    pf.setName("Mary-James Williams");
    idsListAccess = identityManager.getIdentitiesByProfileFilter(providerId, pf, false);
    assertEquals(1, idsListAccess.getSize());

    //
    List<ExoSocialActivity> activities =
        activityManager.getActivitiesWithListAccess(identity).loadAsList(0, 20);
    for (ExoSocialActivity act : activities) {
      List<ExoSocialActivity> comments =
          activityManager.getCommentsWithListAccess(act).loadAsList(0, 20);
      for (ExoSocialActivity cmt : comments) {
        activityManager.deleteComment(act, cmt);
      }
      activityManager.deleteActivity(act);
    }
    userHandler.removeUser(user.getUserName(), false);
  }
Example #13
0
  /** Test {@link IdentityManager#getOrCreateIdentity(String, String)} */
  public void testGetOrCreateIdentity() {
    final String username1 = "john";
    final String username2 = "root";
    Identity gotIdentity1;
    Identity gotIdentity2;
    // load profile = true
    {
      gotIdentity1 =
          identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME, username1, true);

      Profile profile1 = gotIdentity1.getProfile();

      assertNotNull("gotIdentity1.getId() must not be null", gotIdentity1.getId());
      assertNotNull("profile1.getId() must not be null", profile1.getId());
      assertNotNull(
          "profile1.getProperty(Profile.FIRST_NAME) must not be null",
          profile1.getProperty(Profile.FIRST_NAME));
      assertNotNull(
          "profile1.getProperty(Profile.LAST_NAME must not be null",
          profile1.getProperty(Profile.LAST_NAME));
      assertFalse(
          "profile1.getFullName().isEmpty() must return false", profile1.getFullName().isEmpty());

      assertNotNull("gotIdentity1.getId() must not be null", gotIdentity1.getId());
      Identity regotIdentity =
          identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME, username1, true);

      assertNotNull("regotIdentity.getId() must not be null", regotIdentity.getId());
      assertNotNull(
          "regotIdentity.getProfile().getId() must not be null",
          regotIdentity.getProfile().getId());
    }

    // load profile = false
    {
      gotIdentity2 =
          identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME, username2, false);
      assertNotNull("gotIdentity2.getId() must not be null", gotIdentity2.getId());

      assertNotNull(
          "gotIdentity2.getProfile().getId() must not be null", gotIdentity2.getProfile().getId());
    }

    ActivityManager activityManager =
        (ActivityManager) getContainer().getComponentInstanceOfType(ActivityManager.class);

    assertEquals(
        "activityManager.getActivities(gotIdentity1).size() must be 0",
        0,
        activityManager.getActivities(gotIdentity1).size());
    assertEquals(
        "activityManager.getActivities(gotIdentity2).size() must be 0",
        0,
        activityManager.getActivities(gotIdentity2).size());

    // FIXME hoatle fix the problem of getIdentity from a provider but also
    // saved on JCR
    /*
     * GlobalId globalId1 = new GlobalId(OrganizationIdentityProvider.NAME +
     * GlobalId.SEPARATOR + username1); GlobalId globalId2 = new
     * GlobalId(OrganizationIdentityProvider.NAME + GlobalId.SEPARATOR +
     * username2);
     * tearDownIdentityList.add(identityManager.getIdentity(globalId1
     * .toString())); //identity.getId() = null ????
     * tearDownIdentityList.add(identityManager
     * .getIdentity(globalId2.toString())); //identity.getId() = null ????
     */
    tearDownIdentityList.add(identityManager.getIdentity(gotIdentity1.getId()));
    tearDownIdentityList.add(identityManager.getIdentity(gotIdentity2.getId()));
  }
Example #14
0
 static {
   // register all activities here
   ActivityManager.RegisterActivity("main", starwisp.class);
 };