use of org.awesomeapp.messenger.util.Languages in project Zom-Android by zom.
the class SettingActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
pm = getPackageManager();
mOtrMode = (ListPreference) findPreference("pref_security_otr_mode");
mOtrMode.setEntries(Preferences.getOtrModeNames());
mOtrMode.setEntryValues(Preferences.getOtrModeValues());
mOtrMode.setDefaultValue(Preferences.DEFAULT_OTR_MODE);
mAllowScreenshot = (CheckBoxPreference) findPreference("prefBlockScreenshots");
mPanicTriggerApp = (ListPreference) findPreference("pref_panic_trigger_app");
mPanicConfig = (Preference) findPreference("pref_panic_config");
mLanguage = (ListPreference) findPreference("pref_language");
// mLinkifyOnTor = (CheckBoxPreference) findPreference("pref_linkify_on_tor");
mHideOfflineContacts = (CheckBoxPreference) findPreference("pref_hide_offline_contacts");
mDeleteUnsecuredMedia = (CheckBoxPreference) findPreference("pref_delete_unsecured_media");
mEnableNotification = (CheckBoxPreference) findPreference("pref_enable_notification");
mNotificationVibrate = (CheckBoxPreference) findPreference("pref_notification_vibrate");
mNotificationSound = (CheckBoxPreference) findPreference("pref_notification_sound");
mNotificationRingtone = findPreference("pref_notification_ringtone");
Languages languages = Languages.get(this);
currentLanguage = getResources().getConfiguration().locale.getLanguage();
mLanguage.setDefaultValue(currentLanguage);
mLanguage.setEntries(languages.getAllNames());
mLanguage.setEntryValues(languages.getSupportedLocales());
mLanguage.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String language = (String) newValue;
ImApp.resetLanguage(SettingActivity.this, language);
setResult(RESULT_OK);
return true;
}
});
mAllowScreenshot.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
setResult(RESULT_OK);
return true;
}
});
mPanicTriggerApp.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String packageName = (String) newValue;
PanicResponder.setTriggerPackageName(SettingActivity.this, packageName);
PanicResponder.configTriggerAppListPreference(mPanicTriggerApp, R.string.panic_trigger_app_summary, R.string.panic_app_none_summary);
return true;
}
});
mPanicConfig.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent intent = new Intent(SettingActivity.this, PanicSetupActivity.class);
startActivity(intent);
return true;
}
});
findPreference("pref_color_reset").setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(SettingActivity.this);
SharedPreferences.Editor pEdit = settings.edit();
pEdit.remove("themeColorBg");
pEdit.remove("themeColorText");
pEdit.remove("themeColor");
pEdit.commit();
setResult(RESULT_OK);
finish();
return true;
}
});
mNotificationRingtone.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, getString(R.string.notification_ringtone_title));
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, Preferences.getNotificationRingtoneUri());
startActivityForResult(intent, CHOOSE_RINGTONE);
return true;
}
});
mForegroundService = (CheckBoxPreference) findPreference("pref_foreground_enable");
mForegroundService.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
((ImApp) getApplication()).forceStopImService();
return true;
}
});
mHeartbeatInterval = (EditTextPreference) findPreference("pref_heartbeat_interval");
findPreference("prefAdvancedNetworking").setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
RemoteImService.installTransports(getApplicationContext());
return true;
}
});
}
use of org.awesomeapp.messenger.util.Languages 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