Commit 4aed3d16 by Kazuyuki Hida

ログアウト処理をLogoutHelperに移設

parent 2a3ce8ba
package jp.agentec.abook.abv.ui.common.helper;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.widget.Toast;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.logic.AbstractLogic;
import jp.agentec.abook.abv.bl.logic.UserAuthenticateLogic;
import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.abook.abv.ui.common.appinfo.AppDefType;
import jp.agentec.abook.abv.ui.common.util.ABVToastUtil;
import jp.agentec.abook.abv.ui.home.activity.ABookSettingActivity;
import jp.agentec.abook.abv.ui.home.activity.LoginActivity;
public class LogoutHelper {
public static void logout(Activity activity) {
try {
// modify by Jang 2013.06.20
UserAuthenticateLogic user = AbstractLogic.getLogic(UserAuthenticateLogic.class);
// ログイン情報がある場合のみログアウト処理を行う
if (user.getMemberInfo() != null) {
user.signoutUser();
// Widgetへ通知
Intent intent = new Intent();
activity.sendBroadcast(intent);
}
} catch (Exception e) {
Logger.w("signoutUser failed at callLoginActivity", e);
ABVToastUtil.showMakeText(activity, R.string.ERROR, Toast.LENGTH_SHORT);
}
// 新着更新が実行されている場合停止
((ABookSettingActivity)activity).stopContentRefresher();
SharedPreferences sharedPreferences = activity.getSharedPreferences(AppDefType.PrefName.USER_PREFERENCE, Context.MODE_PRIVATE);
sharedPreferences.edit().remove(AppDefType.UserPrefKey.GUEST_LOGIN).apply();
Intent intent = new Intent(activity, LoginActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
activity.startActivity(intent);
activity.finish();
}
}
...@@ -56,6 +56,7 @@ import jp.agentec.abook.abv.launcher.android.R; ...@@ -56,6 +56,7 @@ import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.abook.abv.ui.common.appinfo.AppDefType; import jp.agentec.abook.abv.ui.common.appinfo.AppDefType;
import jp.agentec.abook.abv.ui.common.appinfo.AppDefType.UserPrefKey; import jp.agentec.abook.abv.ui.common.appinfo.AppDefType.UserPrefKey;
import jp.agentec.abook.abv.ui.common.dialog.ABookAlertDialog; import jp.agentec.abook.abv.ui.common.dialog.ABookAlertDialog;
import jp.agentec.abook.abv.ui.common.helper.LogoutHelper;
import jp.agentec.abook.abv.ui.common.helper.ProgressDialogHelper; import jp.agentec.abook.abv.ui.common.helper.ProgressDialogHelper;
import jp.agentec.abook.abv.ui.common.util.ABVToastUtil; import jp.agentec.abook.abv.ui.common.util.ABVToastUtil;
import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil; import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil;
...@@ -176,43 +177,13 @@ public class ABookSettingFragment extends PreferenceFragment { ...@@ -176,43 +177,13 @@ public class ABookSettingFragment extends PreferenceFragment {
logoutAkert.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.confirm), new DialogInterface.OnClickListener() { logoutAkert.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.confirm), new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
logout(); LogoutHelper.logout(getActivity());
} }
}); });
logoutAkert.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(R.string.cancel), (DialogInterface.OnClickListener) null); logoutAkert.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(R.string.cancel), (DialogInterface.OnClickListener) null);
showAlertDialog(logoutAkert); showAlertDialog(logoutAkert);
} }
private void logout() {
try {
// modify by Jang 2013.06.20
UserAuthenticateLogic user = AbstractLogic.getLogic(UserAuthenticateLogic.class);
// ログイン情報がある場合のみログアウト処理を行う
if (user.getMemberInfo() != null) {
user.signoutUser();
// Widgetへ通知
Intent intent = new Intent();
getActivity().sendBroadcast(intent);
}
} catch (Exception e) {
Logger.w("signoutUser failed at callLoginActivity", e);
ABVToastUtil.showMakeText(getActivity(), R.string.ERROR, Toast.LENGTH_SHORT);
}
// 新着更新が実行されている場合停止
((ABookSettingActivity)getActivity()).stopContentRefresher();
SharedPreferences sharedPreferences = getActivity().getSharedPreferences(AppDefType.PrefName.USER_PREFERENCE, Context.MODE_PRIVATE);
sharedPreferences.edit().remove(AppDefType.UserPrefKey.GUEST_LOGIN).commit();
Intent intent = new Intent(getActivity(), LoginActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);
getActivity().finish();
}
private void setLogInfoSetting() { private void setLogInfoSetting() {
PreferenceGroup logInfo = (PreferenceGroup) findPreference(LOG_INFO); PreferenceGroup logInfo = (PreferenceGroup) findPreference(LOG_INFO);
// ログExport // ログExport
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment