use of org.awesomeapp.messenger.ui.legacy.SimpleAlertHandler in project Zom-Android by zom.
the class ImUrlActivity method signInAccount.
private void signInAccount(long accountId, long providerId, String password) {
// editAccount(accountId);
// TODO sign in? security implications?
SignInHelper signInHelper = new SignInHelper(this, new SimpleAlertHandler(this));
signInHelper.setSignInListener(new SignInHelper.SignInListener() {
public void connectedToService() {
}
public void stateChanged(int state, long accountId) {
if (state == ImConnection.LOGGED_IN) {
mHandlerRouter.post(new Runnable() {
public void run() {
handleIntent();
}
});
}
}
});
signInHelper.signIn(password, providerId, accountId, true);
}
use of org.awesomeapp.messenger.ui.legacy.SimpleAlertHandler in project Zom-Android by zom.
the class AddContactActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setTitle("");
mApp = (ImApp) getApplication();
mHandler = new SimpleAlertHandler(this);
setContentView(R.layout.add_contact_activity);
TextView label = (TextView) findViewById(R.id.input_contact_label);
mNewAddress = (EditText) findViewById(R.id.email);
mNewAddress.addTextChangedListener(mTextWatcher);
mNewAddress.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
if (actionId == EditorInfo.IME_ACTION_SEND) {
inviteBuddies();
}
return false;
}
});
Intent intent = getIntent();
String scheme = intent.getScheme();
if (TextUtils.equals(scheme, "xmpp")) {
addContactFromUri(intent.getData());
}
setupActions();
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
use of org.awesomeapp.messenger.ui.legacy.SimpleAlertHandler in project Zom-Android by zom.
the class AccountViewFragment method initFragment.
private void initFragment() {
Intent i = getIntent();
mApp = (ImApp) getActivity().getApplication();
String action = i.getAction();
if (i.hasExtra("isSignedIn"))
isSignedIn = i.getBooleanExtra("isSignedIn", false);
final ProviderDef provider;
mSignInHelper = new SignInHelper(getActivity(), new SimpleAlertHandler(getActivity()));
SignInHelper.SignInListener signInListener = new SignInHelper.SignInListener() {
@Override
public void connectedToService() {
}
@Override
public void stateChanged(int state, long accountId) {
if (state == ImConnection.LOGGED_IN) {
// mSignInHelper.goToAccount(accountId);
// finish();
isSignedIn = true;
} else {
isSignedIn = false;
}
}
};
mSignInHelper.setSignInListener(signInListener);
ContentResolver cr = getActivity().getContentResolver();
Uri uri = i.getData();
// check if there is account information and direct accordingly
if (Intent.ACTION_INSERT_OR_EDIT.equals(action)) {
if ((uri == null) || !Imps.Account.CONTENT_ITEM_TYPE.equals(cr.getType(uri))) {
action = Intent.ACTION_INSERT;
} else {
action = Intent.ACTION_EDIT;
}
}
if (Intent.ACTION_INSERT.equals(action) && uri.getScheme().equals("ima")) {
ImPluginHelper helper = ImPluginHelper.getInstance(getActivity());
String authority = uri.getAuthority();
String[] userpass_host = authority.split("@");
String[] user_pass = userpass_host[0].split(":");
mUserName = user_pass[0].toLowerCase(Locale.getDefault());
String pass = user_pass[1];
mDomain = userpass_host[1].toLowerCase(Locale.getDefault());
mPort = 0;
final boolean regWithTor = i.getBooleanExtra("useTor", false);
Cursor cursor = openAccountByUsernameAndDomain(cr);
boolean exists = cursor.moveToFirst();
long accountId;
if (exists) {
accountId = cursor.getLong(0);
mAccountUri = ContentUris.withAppendedId(Imps.Account.CONTENT_URI, accountId);
pass = cursor.getString(ACCOUNT_PASSWORD_COLUMN);
setAccountKeepSignedIn(true);
mSignInHelper.activateAccount(mProviderId, accountId);
mSignInHelper.signIn(pass, mProviderId, accountId, true);
// setResult(RESULT_OK);
cursor.close();
// finish();
return;
} else {
// xmpp FIXME
mProviderId = helper.createAdditionalProvider(helper.getProviderNames().get(0));
accountId = ImApp.insertOrUpdateAccount(cr, mProviderId, -1, mUserName, mUserName, pass);
mAccountUri = ContentUris.withAppendedId(Imps.Account.CONTENT_URI, accountId);
mSignInHelper.activateAccount(mProviderId, accountId);
createNewAccount(mUserName, pass, accountId, regWithTor);
cursor.close();
return;
}
} else if (Intent.ACTION_INSERT.equals(action)) {
mOriginalUserAccount = "";
// TODO once we implement multiple IM protocols
mProviderId = ContentUris.parseId(uri);
provider = mApp.getProvider(mProviderId);
} else if (Intent.ACTION_EDIT.equals(action)) {
if ((uri == null) || !Imps.Account.CONTENT_ITEM_TYPE.equals(cr.getType(uri))) {
LogCleaner.warn(ImApp.LOG_TAG, "<AccountActivity>Bad data");
return;
}
isEdit = true;
Cursor cursor = cr.query(uri, ACCOUNT_PROJECTION, null, null, null);
if (cursor == null) {
return;
}
if (!cursor.moveToFirst()) {
cursor.close();
return;
}
mAccountId = cursor.getLong(cursor.getColumnIndexOrThrow(BaseColumns._ID));
mProviderId = cursor.getLong(ACCOUNT_PROVIDER_COLUMN);
provider = mApp.getProvider(mProviderId);
Cursor pCursor = cr.query(Imps.ProviderSettings.CONTENT_URI, new String[] { Imps.ProviderSettings.NAME, Imps.ProviderSettings.VALUE }, Imps.ProviderSettings.PROVIDER + "=?", new String[] { Long.toString(mProviderId) }, null);
Imps.ProviderSettings.QueryMap settings = new Imps.ProviderSettings.QueryMap(pCursor, cr, mProviderId, false, /* don't keep updated */
null);
try {
mOriginalUserAccount = cursor.getString(ACCOUNT_USERNAME_COLUMN) + "@" + settings.getDomain();
mEditUserAccount.setText(mOriginalUserAccount);
mEditPass.setText(cursor.getString(ACCOUNT_PASSWORD_COLUMN));
// mRememberPass.setChecked(!cursor.isNull(ACCOUNT_PASSWORD_COLUMN));
// mUseTor.setChecked(settings.getUseTor());
mBtnQrDisplay.setVisibility(View.VISIBLE);
} finally {
settings.close();
cursor.close();
}
} else {
LogCleaner.warn(ImApp.LOG_TAG, "<AccountActivity> unknown intent action " + action);
return;
}
setupUIPost();
}
use of org.awesomeapp.messenger.ui.legacy.SimpleAlertHandler in project Zom-Android by zom.
the class OnboardingActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mShowSplash = getIntent().getBooleanExtra("showSplash", true);
setContentView(R.layout.awesome_onboarding);
if (mShowSplash) {
getSupportActionBar().hide();
} else {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
}
getSupportActionBar().setTitle("");
mHandler = new SimpleAlertHandler(this);
View viewSplash = findViewById(R.id.flipViewMain);
View viewRegister = findViewById(R.id.flipViewRegister);
View viewCreate = findViewById(R.id.flipViewCreateNew);
View viewLogin = findViewById(R.id.flipViewLogin);
View viewInvite = findViewById(R.id.flipViewInviteFriends);
View viewAdvanced = findViewById(R.id.flipViewAdvanced);
final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
int themeColorHeader = settings.getInt("themeColor", -1);
if (themeColorHeader != -1)
viewInvite.setBackgroundColor(themeColorHeader);
mViewFlipper = (ViewFlipper) findViewById(R.id.viewFlipper1);
mEditUsername = (EditText) viewCreate.findViewById(R.id.edtNewName);
mSpinnerDomains = (EditText) viewAdvanced.findViewById(R.id.spinnerDomains);
// ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
// android.R.layout.simple_dropdown_item_1line, OnboardingManager.getServers(this));
// mSpinnerDomains.setAdapter(adapter);
mDomainList = new ListPopupWindow(this);
mDomainList.setAdapter(new ArrayAdapter(this, android.R.layout.simple_dropdown_item_1line, OnboardingManager.getServers(this)));
mDomainList.setAnchorView(mSpinnerDomains);
mDomainList.setWidth(600);
mDomainList.setHeight(400);
mDomainList.setModal(false);
mDomainList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
mSpinnerDomains.setText(OnboardingManager.getServers(OnboardingActivity.this)[position]);
mDomainList.dismiss();
}
});
mSpinnerDomains.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mDomainList.show();
}
});
mSpinnerDomains.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus)
mDomainList.show();
}
});
mImageAvatar = (ImageView) viewCreate.findViewById(R.id.imageAvatar);
mImageAvatar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startAvatarTaker();
}
});
setAnimLeft();
ImageView imageLogo = (ImageView) viewSplash.findViewById(R.id.imageLogo);
imageLogo.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
setAnimLeft();
showOnboarding();
}
});
View btnStartOnboardingNext = viewSplash.findViewById(R.id.nextButton);
btnStartOnboardingNext.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
setAnimLeft();
showOnboarding();
}
});
View btnShowCreate = viewRegister.findViewById(R.id.btnShowRegister);
btnShowCreate.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
setAnimLeft();
showSetupScreen();
}
});
View btnShowLogin = viewRegister.findViewById(R.id.btnShowLogin);
btnShowLogin.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
setAnimLeft();
showLoginScreen();
}
});
View btnShowAdvanced = viewCreate.findViewById(R.id.btnAdvanced);
btnShowAdvanced.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
setAnimLeft();
showAdvancedScreen();
}
});
// set up language chooser button
View languageButton = viewSplash.findViewById(R.id.languageButton);
languageButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final Activity activity = OnboardingActivity.this;
final Languages languages = Languages.get(activity);
final ArrayAdapter<String> languagesAdapter = new ArrayAdapter<String>(activity, android.R.layout.simple_list_item_single_choice, languages.getAllNames());
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setIcon(R.drawable.ic_settings_language);
builder.setTitle(R.string.KEY_PREF_LANGUAGE_TITLE);
builder.setAdapter(languagesAdapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int position) {
String[] languageCodes = languages.getSupportedLocales();
ImApp.resetLanguage(activity, languageCodes[position]);
dialog.dismiss();
}
});
builder.show();
}
});
mEditUsername.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_NULL || actionId == EditorInfo.IME_ACTION_GO || actionId == EditorInfo.IME_ACTION_NEXT || actionId == EditorInfo.IME_ACTION_DONE) {
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
Handler threadHandler = new Handler();
imm.hideSoftInputFromWindow(v.getWindowToken(), 0, new ResultReceiver(threadHandler) {
@Override
protected void onReceiveResult(int resultCode, Bundle resultData) {
super.onReceiveResult(resultCode, resultData);
mNickname = mEditUsername.getText().toString();
if (mNickname.length() > 0) {
startAccountSetup();
}
}
});
return true;
}
return false;
}
});
View btnCreateAdvanced = viewAdvanced.findViewById(R.id.btnNewRegister);
btnCreateAdvanced.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
View viewEdit = findViewById(R.id.edtNameAdvanced);
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(viewEdit.getWindowToken(), 0);
startAdvancedSetup();
}
});
View btnInviteSms = viewInvite.findViewById(R.id.btnInviteSMS);
btnInviteSms.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
doInviteSMS();
}
});
View btnInviteShare = viewInvite.findViewById(R.id.btnInviteShare);
btnInviteShare.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
doInviteShare();
}
});
View btnInviteQR = viewInvite.findViewById(R.id.btnInviteScan);
btnInviteQR.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
doInviteScan();
}
});
View btnSignIn = viewLogin.findViewById(R.id.btnSignIn);
btnSignIn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
doExistingAccountRegister();
}
});
if (!mShowSplash) {
setAnimLeft();
showOnboarding();
}
}
Aggregations