Change time seconds to milliseconds to match with Android timestamp

This commit is contained in:
Erwan Croze 2016-11-14 16:54:18 +01:00
parent 8d741c7fe3
commit 26e4ca0131
6 changed files with 27 additions and 13 deletions

View file

@ -12,7 +12,7 @@
<!-- Phone numbers -->
<bool name="use_phone_number_validation">true</bool><!-- Use phone number for validation -->
<integer name="popup_time_interval">86400</integer><!-- Time between two inapp notifications in seconds -->
<integer name="popup_time_interval">86400000</integer><!-- Time between two inapp notifications in milliseconds -->
<!-- Assistant -->
<bool name="assistant_allow_username">true</bool> <!-- Allow to use an username instead of the phone number for account creation -->
@ -38,7 +38,7 @@
<!-- Inapp -->
<bool name="enable_in_app_purchase">false</bool>
<integer name="days_notification_shown">5</integer><!-- Notification shown before end of trial version in days -->
<integer name="time_between_inapp_notification">86400</integer><!-- Time between two inapp notifications in seconds -->
<integer name="time_between_inapp_notification">86400000</integer><!-- Time between two inapp notifications in milliseconds -->
<bool name="hide_username_in_inapp">true</bool>
<!-- Push notification settings -->

View file

@ -262,6 +262,7 @@ public class AccountPreferencesFragment extends PreferencesListFragment implemen
Intent assistant = new Intent();
assistant.setClass(LinphoneActivity.instance(), AssistantActivity.class);
assistant.putExtra("LinkPhoneNumber", true);
assistant.putExtra("FromPref", true);
startActivity(assistant);
return true;
}

View file

@ -230,11 +230,9 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
if(getResources().getBoolean(R.bool.use_phone_number_validation)) {
if (state.equals(RegistrationState.RegistrationOk)) {
if (LinphonePreferences.instance().getLinkPopupTime() == null || (LinphonePreferences.instance().getLinkPopupTime() != null)) {
LinphoneManager.getInstance().isAccountWithAlias();
}
}
}
if(state.equals(RegistrationState.RegistrationFailed) && newProxyConfig) {
newProxyConfig = false;
@ -1743,7 +1741,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
public void displayInappNotification(String date) {
Timestamp now = new Timestamp(new Date().getTime());
if (LinphonePreferences.instance().getInappPopupTime() != null && Long.parseLong(LinphonePreferences.instance().getInappPopupTime()) < now.getTime()) {
if (LinphonePreferences.instance().getInappPopupTime() != null && Long.parseLong(LinphonePreferences.instance().getInappPopupTime()) > now.getTime()) {
return;
} else {
long newDate = now.getTime() + getResources().getInteger(R.integer.time_between_inapp_notification);

View file

@ -37,6 +37,7 @@ import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import org.linphone.assistant.AssistantActivity;
import org.linphone.core.CallDirection;
import org.linphone.core.LinphoneAccountCreator;
import org.linphone.core.LinphoneAddress;
@ -1451,9 +1452,9 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
public void isAccountWithAlias(){
if(LinphoneManager.getLc().getDefaultProxyConfig() != null) {
Timestamp now = new Timestamp(new Date().getTime());
long now = new Timestamp(new Date().getTime()).getTime();
if (LinphonePreferences.instance().getLinkPopupTime() == null
|| Long.parseLong(LinphonePreferences.instance().getLinkPopupTime()) > now.getTime()) {
|| Long.parseLong(LinphonePreferences.instance().getLinkPopupTime()) < now) {
accountCreator.setUsername(LinphonePreferences.instance().getAccountUsername(LinphonePreferences.instance().getDefaultAccountIndex()));
accountCreator.isAccountUsed();
}
@ -1463,8 +1464,9 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
}
private void askLinkWithPhoneNumber(){
Timestamp now = new Timestamp(new Date().getTime());
long newDate = now.getTime() + LinphoneActivity.instance().getResources().getInteger(R.integer.popup_time_interval);
long now = new Timestamp(new Date().getTime()).getTime();
long future = new Timestamp(LinphoneActivity.instance().getResources().getInteger(R.integer.popup_time_interval)).getTime();
long newDate = now + future;
LinphonePreferences.instance().setLinkPopupTime(String.valueOf(newDate));
@ -1477,7 +1479,11 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
delete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
LinphoneManager.getInstance().displayLinkPhoneNumber();
Intent assistant = new Intent();
assistant.setClass(LinphoneActivity.instance(), AssistantActivity.class);
assistant.putExtra("LinkPhoneNumber", true);
assistant.putExtra("LinkPhoneNumberAsk", true);
mServiceContext.startActivity(assistant);
dialog.dismiss();
}
});

View file

@ -83,7 +83,7 @@ private static AssistantActivity instance;
private AssistantFragmentsEnum firstFragment;
private Fragment fragment;
private LinphonePreferences mPrefs;
private boolean accountCreated = false, newAccount = false, isLink = false;
private boolean accountCreated = false, newAccount = false, isLink = false, fromPref = false;
private LinphoneCoreListenerBase mListener;
private LinphoneAddress address;
private StatusFragment status;
@ -112,6 +112,8 @@ private static AssistantActivity instance;
if (getIntent().getBooleanExtra("LinkPhoneNumber",false)) {
isLink = true;
if (getIntent().getBooleanExtra("FromPref",false))
fromPref = true;
displayCreateAccount();
} else {
firstFragment = getResources().getBoolean(R.bool.assistant_use_linphone_login_as_first_fragment) ? AssistantFragmentsEnum.LINPHONE_LOGIN : AssistantFragmentsEnum.WELCOME;
@ -400,6 +402,7 @@ private static AssistantActivity instance;
fragment = new CreateAccountFragment();
Bundle extra = new Bundle();
extra.putBoolean("LinkPhoneNumber", isLink);
extra.putBoolean("LinkFromPref", fromPref);
fragment.setArguments(extra);
changeFragment(fragment);
currentFragment = AssistantFragmentsEnum.CREATE_ACCOUNT;

View file

@ -39,6 +39,7 @@ import android.accounts.AccountManager;
import android.app.AlertDialog;
import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.telephony.TelephonyManager;
@ -302,7 +303,12 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
}
case R.id.assistant_skip: {
if (getArguments().getBoolean("LinkFromPref")) {
startActivity(new Intent().setClass(AssistantActivity.instance(), LinphoneActivity.class));
AssistantActivity.instance().finish();
} else {
AssistantActivity.instance().success();
}
break;
}