use of com.voipgrid.vialer.Preferences in project vialer-android by VoIPGRID.
the class SetupActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_setup);
mJsonStorage = new JsonStorage(this);
mPreferences = new Preferences(this);
// Forced logging due to user not being able to set/unset it at this point.
mRemoteLogger = new RemoteLogger(SetupActivity.class).forceRemoteLogging(true);
Fragment gotoFragment = null;
Integer fragmentId = null;
Bundle bundle = getIntent().getExtras();
if (bundle != null) {
fragmentId = bundle.getInt("fragment");
mActivityToReturnToName = bundle.getString("activity");
if (fragmentId == R.id.fragment_voip_account_missing) {
gotoFragment = ((SetUpVoipAccountFragment) getFragmentManager().findFragmentById(fragmentId)).newInstance();
} else if (fragmentId == R.id.fragment_account) {
SystemUser systemUser = (SystemUser) mJsonStorage.get(SystemUser.class);
gotoFragment = ((AccountFragment) getFragmentManager().findFragmentById(fragmentId)).newInstance(systemUser.getMobileNumber(), systemUser.getOutgoingCli());
}
}
if (findViewById(R.id.fragment_container) != null) {
if (gotoFragment == null) {
gotoFragment = LogoFragment.newInstance();
}
if (fragmentId != null && fragmentId == R.id.fragment_account) {
swapFragment(gotoFragment, AccountFragment.class.getSimpleName());
} else {
swapFragment(gotoFragment, gotoFragment.getClass().getSimpleName());
}
}
}
use of com.voipgrid.vialer.Preferences in project vialer-android by VoIPGRID.
the class ConnectivityHelper method hasFastData.
/**
* Check if the device is connected via wifi or LTE connection.
* @return
*/
public boolean hasFastData() {
Preferences pref = new Preferences(mContext);
Connection connectionType = getConnectionType();
return sFastDataTypes.contains(connectionType) || (sFast3GDataTypes.contains(connectionType) && pref.has3GEnabled());
}
use of com.voipgrid.vialer.Preferences in project vialer-android by VoIPGRID.
the class LoginRequiredActivity method onResume.
@Override
protected void onResume() {
super.onResume();
Preferences prefs = new Preferences(this);
if (!prefs.isLoggedIn() && prefs.finishedOnboarding()) {
new RemoteLogger(LoginRequiredActivity.class).w("Not logged in anymore! Redirecting to onboarding");
// Go to onboarding.
Intent intent = new Intent(new Intent(this, SetupActivity.class));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
finish();
}
}
use of com.voipgrid.vialer.Preferences in project vialer-android by VoIPGRID.
the class WelcomeFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mPreferences = new Preferences(getActivity());
}
use of com.voipgrid.vialer.Preferences in project vialer-android by VoIPGRID.
the class MiddlewareHelper method register.
public static void register(final Context context, String token) {
Preferences sipPreferences = new Preferences(context);
Tracker analyticsTracker = ((AnalyticsApplication) context.getApplicationContext()).getDefaultTracker();
final AnalyticsHelper analyticsHelper = new AnalyticsHelper(analyticsTracker);
if (!sipPreferences.canUseSip()) {
return;
}
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
final SharedPreferences.Editor editor = preferences.edit();
editor.putLong(LAST_REGISTRATION, System.currentTimeMillis());
JsonStorage jsonStorage = new JsonStorage(context);
AccountHelper accountHelper = new AccountHelper(context);
if (!jsonStorage.has(PhoneAccount.class)) {
return;
}
Registration api = ServiceGenerator.createService(context, Registration.class, getBaseApiUrl(context), accountHelper.getEmail(), accountHelper.getPassword());
String sipUserId = ((PhoneAccount) jsonStorage.get(PhoneAccount.class)).getAccountId();
String fullName = ((SystemUser) jsonStorage.get(SystemUser.class)).getFullName();
String appName = context.getPackageName();
Call<ResponseBody> call = api.register(fullName, token, sipUserId, Build.VERSION.CODENAME, Build.VERSION.RELEASE, appName);
editor.putString(CURRENT_TOKEN, token);
call.enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(@NonNull Call<ResponseBody> call, @NonNull Response<ResponseBody> response) {
if (response.isSuccessful()) {
setRegistrationStatus(context, STATUS_REGISTERED);
} else {
setRegistrationStatus(context, STATUS_FAILED);
analyticsHelper.sendException(context.getString(R.string.analytics_event_description_registration_failed));
}
editor.apply();
}
@Override
public void onFailure(@NonNull Call<ResponseBody> call, @NonNull Throwable t) {
t.printStackTrace();
setRegistrationStatus(context, STATUS_FAILED);
}
});
}
Aggregations