Add notification for trial account and add boolean for interface customization
This commit is contained in:
parent
e270bb6b6d
commit
59be616a43
16 changed files with 231 additions and 174 deletions
|
@ -15,6 +15,7 @@
|
|||
|
||||
<LinearLayout
|
||||
android:id="@+id/topbar"
|
||||
android:layout_below="@+id/status"
|
||||
android:background="@color/colorF"
|
||||
android:orientation="horizontal"
|
||||
android:layout_gravity="center_horizontal"
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/username_layout"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
|
|
@ -1,80 +1,82 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<!-- New settings -->
|
||||
<string name="default_domain">sip.linphone.org</string>
|
||||
<string name="default_stun">stun.linphone.org</string>
|
||||
|
||||
<!-- Global -->
|
||||
<string name="default_domain">sip.linphone.org</string><!-- Set the default domain used for account creation/addresses -->
|
||||
<string name="sync_account_type">org.linphone</string> <!-- Change package ! -->
|
||||
<string name="sync_mimetype">vnd.android.cursor.item/org.linphone.profile</string> <!-- Change package, leave .profile at the end. Also change res/xml/contacts.xml ! -->
|
||||
|
||||
<bool name="assistant_use_linphone_login_as_first_fragment">false</bool>
|
||||
<bool name="assistant_allow_username">true</bool> <!-- Allow to use an username instead of the phone number for account creation -->
|
||||
<bool name="hide_in_call_stats">false</bool>
|
||||
<bool name="orientation_portrait_only">false</bool>
|
||||
<bool name="show_statusbar_only_on_dialer">false</bool>
|
||||
<bool name="replace_assistant_with_old_interface">false</bool>
|
||||
<bool name="force_use_of_linphone_friends">false</bool>
|
||||
<bool name="in_app_purchase_in_settings">false</bool>
|
||||
<bool name="use_friendlist_subscription">true</bool>
|
||||
<bool name="use_linphone_tag">true</bool>
|
||||
|
||||
<string name="wizard_url">https://sip3.linphone.org:444/inapp.php</string>
|
||||
<!-- Assistant -->
|
||||
<string name="wizard_url">https://sip3.linphone.org:444/inapp.php</string><!-- Url of the xmlrpc script -->
|
||||
<bool name="assistant_allow_username">false</bool> <!-- Allow to use an username instead of the phone number for account creation -->
|
||||
<bool name="assistant_use_linphone_login_as_first_fragment">false</bool><!-- Start assistant in loginFragment view instead of menu -->
|
||||
<bool name="replace_assistant_with_old_interface">false</bool>
|
||||
<bool name="hide_assistant">false</bool>
|
||||
<bool name="assistant_cancel_move_to_back">false</bool>
|
||||
<bool name="pre_fill_email_in_assistant">true</bool> <!-- Set the email field of the wizard with one of the gmail account registered on the device -->
|
||||
<bool name="assistant_account_validation_mandatory">false</bool>
|
||||
<bool name="allow_only_phone_numbers_in_assistant">false</bool>
|
||||
<bool name="hide_linphone_accounts_in_assistant">false</bool>
|
||||
<bool name="hide_generic_accounts_in_assistant">false</bool>
|
||||
<bool name="hide_remote_provisioning_in_assistant">false</bool>
|
||||
<bool name="display_account_assistant_at_first_start">true</bool>
|
||||
<bool name="hide_H264_downloader">false</bool><!-- Set the email field of the wizard with one of the gmail account registered on the device -->
|
||||
|
||||
<!-- Remote provisioning -->
|
||||
<bool name="display_sms_remote_provisioning_activity">false</bool>
|
||||
<bool name="forbid_app_usage_until_remote_provisioning_completed">false</bool>
|
||||
<bool name="display_confirmation_popup_after_first_configuration">false</bool>
|
||||
<bool name="allow_cancel_remote_provisioning_login_activity">true</bool>
|
||||
|
||||
<!-- Inapp -->
|
||||
<bool name="enabled_in_app_purchase">true</bool>
|
||||
<bool name="in_app_purchase_in_settings">true</bool>
|
||||
<integer name="number_days_reminder">28</integer><!-- Remind to biy account -->
|
||||
<bool name="hide_username_in_inapp">true</bool>
|
||||
|
||||
<!-- Push notification settings -->
|
||||
<bool name="enable_push_id">true</bool>
|
||||
<string name="push_sender_id">622464153529</string>
|
||||
<bool name="hide_camera_settings">false</bool>
|
||||
<bool name="hide_wizard">false</bool>
|
||||
|
||||
<bool name="disable_chat">false</bool>
|
||||
<bool name="disable_chat_message_notification">false</bool>
|
||||
<bool name="disable_chat_send_file">false</bool>
|
||||
|
||||
<bool name="setup_account_validation_mandatory">false</bool>
|
||||
<bool name="hide_linphone_accounts_wizard">false</bool>
|
||||
<bool name="hide_generic_accounts_wizard">false</bool>
|
||||
<bool name="hide_remote_provisioning_in_wizard">false</bool>
|
||||
<bool name="allow_cancel_remote_provisioning_login_activity">true</bool>
|
||||
<bool name="hide_accounts">false</bool>
|
||||
<bool name="display_account_wizard_at_first_start">true</bool>
|
||||
<bool name="allow_only_phone_numbers_in_wizard">false</bool>
|
||||
|
||||
<bool name="use_linphone_tag">true</bool>
|
||||
|
||||
<bool name="pre_fill_email_in_wizard">true</bool> <!-- Set the email field of the wizard with one of the gmail account registered on the device -->
|
||||
|
||||
<!-- Call -->
|
||||
<bool name="forbid_self_call">false</bool>
|
||||
<bool name="allow_ringing_while_early_media">true</bool>
|
||||
<bool name="allow_transfers">true</bool>
|
||||
<bool name="disable_options_in_call">false</bool>
|
||||
<bool name="automatically_start_intercepted_outgoing_gsm_call">true</bool><!-- This settings handle the behavior of the view waiting for the remote provisioning configuration to be done -->
|
||||
<bool name="hide_camera_settings">false</bool>
|
||||
<bool name="hide_in_call_stats">false</bool>
|
||||
|
||||
<bool name="automatically_start_intercepted_outgoing_gsm_call">true</bool>
|
||||
<!-- This settings handle the behavior of the view waiting for the remote provisioning configuration to be done -->
|
||||
<bool name="display_sms_remote_provisioning_activity">false</bool>
|
||||
<bool name="forbid_app_usage_until_remote_provisioning_completed">false</bool>
|
||||
<bool name="display_confirmation_popup_after_first_configuration">false</bool>
|
||||
<!-- Settings -->
|
||||
<bool name="disable_every_log">false</bool>
|
||||
<bool name="disable_all_security_features_for_markets">false</bool> <!-- Disable TLS/SRTP/ZRTP -->
|
||||
<bool name="disable_all_patented_codecs_for_markets">false</bool> <!-- Disable MPEG4/H264 -->
|
||||
<string name="about_bugreport_email">linphone-android@belledonne-communications.com</string>
|
||||
<bool name="use_friendlist_subscription">true</bool>
|
||||
<string name="default_stun">stun.linphone.org</string>
|
||||
<bool name="hide_accounts">false</bool>
|
||||
|
||||
<!-- Chat -->
|
||||
<bool name="disable_chat">false</bool>
|
||||
<bool name="disable_chat_message_notification">false</bool>
|
||||
<bool name="disable_chat_send_file">false</bool>
|
||||
<string name="temp_photo_name">linphone-android-photo-temp</string>
|
||||
<string name="temp_photo_name_with_date">linphone-android-photo-%s</string>
|
||||
|
||||
<bool name="hide_phone_numbers_in_editor">false</bool>
|
||||
<bool name="hide_sip_addresses_in_editor">false</bool>
|
||||
|
||||
<!-- Contacts -->
|
||||
<bool name="hide_contact_phone_numbers">false</bool>
|
||||
<bool name="hide_contact_sip_addresses">false</bool>
|
||||
|
||||
<bool name="hide_phone_numbers_in_editor">false</bool>
|
||||
<bool name="hide_sip_addresses_in_editor">false</bool>
|
||||
<bool name="allow_only_one_phone_number">false</bool>
|
||||
<bool name="allow_only_one_sip_address">false</bool>
|
||||
|
||||
<bool name="display_contact_organization">true</bool>
|
||||
|
||||
<bool name="setup_cancel_move_to_back">false</bool>
|
||||
|
||||
<!-- Others Parameters-->
|
||||
<string name="about_bugreport_email">linphone-android@belledonne-communications.com</string>
|
||||
<bool name="enable_call_notification">true</bool>
|
||||
<bool name="kill_service_with_task_manager">true</bool>
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
<string name="sync_account_name">linphone contacts</string>
|
||||
<string name="history_date_format">EEE, d MMM</string>
|
||||
<string name="history_detail_date_format">yyyy/MM/dd - HH:mm - </string>
|
||||
<string name="inapp_popup_date_format">yyyy/MM/dd</string>
|
||||
<string name="inapp_popup_date_day">dd</string>
|
||||
<string name="messages_date_format">dd/MM, HH:mm</string>
|
||||
<string name="messages_list_date_format">dd/MM</string>
|
||||
<string name="today_date_format">HH:mm</string>
|
||||
|
@ -118,7 +120,9 @@
|
|||
<string name="transport_unsupported">Unsupported transport</string>
|
||||
|
||||
<!-- In-app -->
|
||||
<string name="inapp">in-app</string>
|
||||
<string name="inapp">In-app</string>
|
||||
<string name="inapp_notification_title">In-app purchase</string>
|
||||
<string name="inapp_notification_content">The trail period expires on %s</string>
|
||||
|
||||
<!-- Dailer -->
|
||||
<string name="address_bar_hint">Enter a number or an address</string>
|
||||
|
|
|
@ -369,7 +369,7 @@ public class AccountPreferencesFragment extends PreferencesListFragment {
|
|||
CheckBoxPreference friendlistSubscribe = (CheckBoxPreference) advanced.getPreference(8);
|
||||
friendlistSubscribe.setOnPreferenceChangeListener(friendlistSubscribeListener);
|
||||
if(!isNewAccount){
|
||||
escape.setChecked(mPrefs.getReplacePlusByZeroZero(n));
|
||||
friendlistSubscribe.setChecked(mPrefs.isFriendlistsubscriptionEnabled());
|
||||
}
|
||||
|
||||
PreferenceCategory manage = (PreferenceCategory) getPreferenceScreen().findPreference(getString(R.string.pref_manage_key));
|
||||
|
|
|
@ -49,7 +49,6 @@ import org.linphone.core.LinphoneProxyConfig;
|
|||
import org.linphone.core.Reason;
|
||||
import org.linphone.mediastream.Log;
|
||||
import org.linphone.purchase.InAppPurchaseActivity;
|
||||
import org.linphone.purchase.InAppPurchaseHelper;
|
||||
import org.linphone.ui.AddressText;
|
||||
import org.linphone.xmlrpc.XmlRpcHelper;
|
||||
import org.linphone.xmlrpc.XmlRpcListenerBase;
|
||||
|
@ -162,7 +161,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
return;
|
||||
}
|
||||
|
||||
boolean useFirstLoginActivity = getResources().getBoolean(R.bool.display_account_wizard_at_first_start);
|
||||
boolean useFirstLoginActivity = getResources().getBoolean(R.bool.display_account_assistant_at_first_start);
|
||||
if (LinphonePreferences.instance().isProvisioningLoginViewEnabled()) {
|
||||
Intent wizard = new Intent();
|
||||
wizard.setClass(this, RemoteProvisioningLoginActivity.class);
|
||||
|
@ -202,9 +201,9 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
initButtons();
|
||||
initSideMenu();
|
||||
|
||||
//ifINAP
|
||||
getTrialAccount();
|
||||
getExpirationAccount();
|
||||
if(getResources().getBoolean(R.bool.enabled_in_app_purchase)){
|
||||
isTrialAccount();
|
||||
}
|
||||
|
||||
currentFragment = FragmentsAvailable.EMPTY;
|
||||
if (savedInstanceState == null) {
|
||||
|
@ -629,6 +628,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
}
|
||||
|
||||
public void displayInapp() {
|
||||
checkAndRequestInappPermission();
|
||||
startActivity(new Intent(LinphoneActivity.this, InAppPurchaseActivity.class));
|
||||
}
|
||||
|
||||
|
@ -1179,6 +1179,10 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
public void checkAndRequestReadContactsPermission() {
|
||||
checkAndRequestPermission(Manifest.permission.READ_CONTACTS, PERMISSIONS_REQUEST_CONTACTS);
|
||||
}
|
||||
|
||||
public void checkAndRequestInappPermission() {
|
||||
checkAndRequestPermission(Manifest.permission.GET_ACCOUNTS, PERMISSIONS_REQUEST_CONTACTS);
|
||||
}
|
||||
|
||||
private boolean willContactsPermissionBeAsked() {
|
||||
return LinphonePreferences.instance().firstTimeAskingForPermission(Manifest.permission.READ_CONTACTS) || ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.READ_CONTACTS);
|
||||
|
@ -1206,6 +1210,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
int readExternalStorage = getPackageManager().checkPermission(Manifest.permission.READ_EXTERNAL_STORAGE, getPackageName());
|
||||
Log.i("[Permission] Read external storage permission is " + (readExternalStorage == PackageManager.PERMISSION_GRANTED ? "granted" : "denied"));
|
||||
int camera = getPackageManager().checkPermission(Manifest.permission.CAMERA, getPackageName());
|
||||
int accounts = getPackageManager().checkPermission(Manifest.permission.GET_ACCOUNTS, getPackageName());
|
||||
Log.i("[Permission] Camera permission is " + (camera == PackageManager.PERMISSION_GRANTED ? "granted" : "denied"));
|
||||
|
||||
if (readExternalStorage != PackageManager.PERMISSION_GRANTED) {
|
||||
|
@ -1394,6 +1399,10 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
String sipUri = extras.getString("ChatContactSipUri");
|
||||
doNotGoToCallActivity = true;
|
||||
displayChat(sipUri);
|
||||
} else if (extras != null && extras.getBoolean("GoToInapp", false)) {
|
||||
LinphoneService.instance().removeMessageNotification();
|
||||
doNotGoToCallActivity = true;
|
||||
displayInapp();
|
||||
} else if (extras != null && extras.getBoolean("Notification", false)) {
|
||||
if (LinphoneManager.getLc().getCallsNb() > 0) {
|
||||
LinphoneCall call = LinphoneManager.getLc().getCalls()[0];
|
||||
|
@ -1461,7 +1470,11 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
public void initSideMenu() {
|
||||
|
||||
sideMenu = (DrawerLayout) findViewById(R.id.side_menu);
|
||||
sideMenuItems = new String[]{getResources().getString(R.string.menu_assistant),getResources().getString(R.string.menu_settings),getResources().getString(R.string.menu_about),"Inapp"};
|
||||
if(getResources().getBoolean(R.bool.in_app_purchase_in_settings)){
|
||||
sideMenuItems = new String[]{getResources().getString(R.string.menu_assistant),getResources().getString(R.string.menu_settings),getResources().getString(R.string.menu_about), getResources().getString(R.string.inapp)};
|
||||
} else {
|
||||
sideMenuItems = new String[]{getResources().getString(R.string.menu_assistant),getResources().getString(R.string.menu_settings),getResources().getString(R.string.menu_about)};
|
||||
}
|
||||
sideMenuContent = (RelativeLayout) findViewById(R.id.side_menu_content);
|
||||
sideMenuItemList = (ListView)findViewById(R.id.item_list);
|
||||
menu = (ImageView) findViewById(R.id.side_menu_button);
|
||||
|
@ -1479,8 +1492,10 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
if (sideMenuItemList.getAdapter().getItem(i).toString().equals(getString(R.string.menu_assistant))) {
|
||||
LinphoneActivity.instance().displayAssistant();
|
||||
}
|
||||
if (sideMenuItemList.getAdapter().getItem(i).toString().equals("Inapp")) {
|
||||
LinphoneActivity.instance().displayInapp();
|
||||
if(getResources().getBoolean(R.bool.in_app_purchase_in_settings)){
|
||||
if (sideMenuItemList.getAdapter().getItem(i).toString().equals(getString(R.string.inapp))) {
|
||||
LinphoneActivity.instance().displayInapp();
|
||||
}
|
||||
}
|
||||
openOrCloseSideMenu(false);
|
||||
}
|
||||
|
@ -1657,17 +1672,17 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
}
|
||||
|
||||
//Inapp Purchase
|
||||
private void getTrialAccount() {
|
||||
private void isTrialAccount() {
|
||||
if(LinphoneManager.getLc().getDefaultProxyConfig() != null) {
|
||||
XmlRpcHelper helper = new XmlRpcHelper();
|
||||
helper.isTrialAccountAsync(new XmlRpcListenerBase() {
|
||||
@Override
|
||||
public void onTrialAccountFetched(boolean isTrial) {
|
||||
if(isTrial){
|
||||
displayInappDialog();
|
||||
if (isTrial) {
|
||||
getExpirationAccount();
|
||||
}
|
||||
}
|
||||
}, LinphonePreferences.instance().getAccountUsername(0), LinphonePreferences.instance().getAccountHa1(0));
|
||||
}, LinphonePreferences.instance().getAccountUsername(LinphonePreferences.instance().getDefaultAccountIndex()), LinphonePreferences.instance().getAccountHa1(LinphonePreferences.instance().getDefaultAccountIndex()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1677,44 +1692,47 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
helper.getAccountExpireAsync(new XmlRpcListenerBase() {
|
||||
@Override
|
||||
public void onAccountExpireFetched(String result) {
|
||||
Log.w("RESULT " + result);
|
||||
if (result != null) {
|
||||
long timestamp = Long.parseLong(result);
|
||||
|
||||
Calendar calresult = Calendar.getInstance();
|
||||
calresult.setTimeInMillis(timestamp);
|
||||
|
||||
int diff = getDiffDays(calresult, Calendar.getInstance());
|
||||
if (diff != -1 && diff <= getResources().getInteger(R.integer.number_days_reminder)) {
|
||||
displayInappNotification(timestampToHumanDate(calresult));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}, LinphonePreferences.instance().getAccountUsername(0), LinphonePreferences.instance().getAccountHa1(0));
|
||||
}, LinphonePreferences.instance().getAccountUsername(LinphonePreferences.instance().getDefaultAccountIndex()), LinphonePreferences.instance().getAccountHa1(LinphonePreferences.instance().getDefaultAccountIndex()));
|
||||
}
|
||||
}
|
||||
|
||||
public Dialog displayInappDialog(){
|
||||
final Dialog dialog = new Dialog(this);
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
Drawable d = new ColorDrawable(ContextCompat.getColor(this, R.color.colorC));
|
||||
d.setAlpha(200);
|
||||
dialog.setContentView(R.layout.input_dialog);
|
||||
dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
|
||||
dialog.getWindow().setBackgroundDrawable(d);
|
||||
|
||||
TextView customText = (TextView) dialog.findViewById(R.id.customText);
|
||||
customText.setText(getString(R.string.error_bad_credentials));
|
||||
|
||||
Button retry = (Button) dialog.findViewById(R.id.retry);
|
||||
Button cancel = (Button) dialog.findViewById(R.id.cancel);
|
||||
|
||||
retry.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
cancel.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
return dialog;
|
||||
public void displayInappNotification(String date) {
|
||||
if (LinphonePreferences.instance().getLastDateNotificationShown() != null && timestampToHumanDate(Calendar.getInstance()).equals(LinphonePreferences.instance().getLastDateNotificationShown())) {
|
||||
return;
|
||||
} else {
|
||||
LinphonePreferences.instance().setLastDateNotificationShown(timestampToHumanDate(Calendar.getInstance()));
|
||||
}
|
||||
LinphoneService.instance().displayInappNotification(String.format(getString(R.string.inapp_notification_content), date));
|
||||
}
|
||||
|
||||
private String timestampToHumanDate(Calendar cal) {
|
||||
SimpleDateFormat dateFormat;
|
||||
dateFormat = new SimpleDateFormat(getResources().getString(R.string.inapp_popup_date_format));
|
||||
return dateFormat.format(cal.getTime());
|
||||
}
|
||||
|
||||
private int getDiffDays(Calendar cal1, Calendar cal2) {
|
||||
if (cal1 == null || cal2 == null) {
|
||||
return -1;
|
||||
}
|
||||
if(cal1.get(Calendar.ERA) == cal2.get(Calendar.ERA) && cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR)){
|
||||
return cal1.get(Calendar.DAY_OF_YEAR) - cal2.get(Calendar.DAY_OF_YEAR);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
interface ContactPicked {
|
||||
|
|
|
@ -1311,6 +1311,14 @@ public class LinphonePreferences {
|
|||
return purchasables;
|
||||
}
|
||||
|
||||
public String getLastDateNotificationShown(){
|
||||
return getConfig().getString("app", "notification_date", null);
|
||||
}
|
||||
|
||||
public void setLastDateNotificationShown(String date){
|
||||
getConfig().setString("app", "notification_date", date);
|
||||
}
|
||||
|
||||
public String getXmlRpcServerUrl() {
|
||||
return getConfig().getString("app", "server_url", null);
|
||||
}
|
||||
|
|
|
@ -455,6 +455,16 @@ public final class LinphoneService extends Service {
|
|||
|
||||
notifyWrapper(MESSAGE_NOTIF_ID, mMsgNotif);
|
||||
}
|
||||
|
||||
public void displayInappNotification(String message) {
|
||||
Intent notifIntent = new Intent(this, LinphoneActivity.class);
|
||||
notifIntent.putExtra("GoToInapp", true);
|
||||
|
||||
PendingIntent notifContentIntent = PendingIntent.getActivity(this, 0, notifIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
mNotif = Compatibility.createSimpleNotification(getApplicationContext(), getString(R.string.inapp_notification_title), message, notifContentIntent);
|
||||
|
||||
notifyWrapper(NOTIF_ID, mNotif);
|
||||
}
|
||||
|
||||
public void removeMessageNotification() {
|
||||
mNM.cancel(MESSAGE_NOTIF_ID);
|
||||
|
|
|
@ -25,8 +25,6 @@ import org.linphone.LinphoneUtils;
|
|||
import org.linphone.LinphonePreferences.AccountBuilder;
|
||||
import org.linphone.R;
|
||||
import org.linphone.StatusFragment;
|
||||
import org.linphone.core.LinphoneAccountCreator;
|
||||
import org.linphone.core.LinphoneAccountCreatorImpl;
|
||||
import org.linphone.core.LinphoneAddress;
|
||||
import org.linphone.core.LinphoneAddress.TransportType;
|
||||
import org.linphone.core.LinphoneCore;
|
||||
|
@ -82,7 +80,6 @@ private static AssistantActivity instance;
|
|||
private boolean remoteProvisioningInProgress;
|
||||
private boolean echoCancellerAlreadyDone;
|
||||
private static final int PERMISSIONS_REQUEST_RECORD_AUDIO = 201;
|
||||
private static final int PERMISSIONS_READ_PHONE_STATE = 202;
|
||||
|
||||
public CountryListFragment.Country country;
|
||||
public String phone_number;
|
||||
|
@ -196,10 +193,6 @@ private static AssistantActivity instance;
|
|||
transaction.commitAllowingStateLoss();
|
||||
}
|
||||
|
||||
public AssistantFragmentsEnum getCurrentFragment() {
|
||||
return currentFragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int id = v.getId();
|
||||
|
@ -207,7 +200,7 @@ private static AssistantActivity instance;
|
|||
if (id == R.id.assistant_cancel) {
|
||||
hideKeyboard();
|
||||
LinphonePreferences.instance().firstLaunchSuccessful();
|
||||
if (getResources().getBoolean(R.bool.setup_cancel_move_to_back)) {
|
||||
if (getResources().getBoolean(R.bool.assistant_cancel_move_to_back)) {
|
||||
moveTaskToBack(true);
|
||||
} else {
|
||||
LinphonePreferences.instance().firstLaunchSuccessful();
|
||||
|
@ -224,7 +217,7 @@ private static AssistantActivity instance;
|
|||
public void onBackPressed() {
|
||||
if (currentFragment == firstFragment) {
|
||||
LinphonePreferences.instance().firstLaunchSuccessful();
|
||||
if (getResources().getBoolean(R.bool.setup_cancel_move_to_back)) {
|
||||
if (getResources().getBoolean(R.bool.assistant_cancel_move_to_back)) {
|
||||
moveTaskToBack(true);
|
||||
} else {
|
||||
LinphonePreferences.instance().firstLaunchSuccessful();
|
||||
|
@ -254,10 +247,6 @@ private static AssistantActivity instance;
|
|||
}
|
||||
}
|
||||
|
||||
public void checkAndRequestReadPhoneState() {
|
||||
checkAndRequestPermission(Manifest.permission.READ_PHONE_STATE, 0);
|
||||
}
|
||||
|
||||
public void checkAndRequestAudioPermission() {
|
||||
checkAndRequestPermission(Manifest.permission.RECORD_AUDIO, 0);
|
||||
}
|
||||
|
@ -393,11 +382,6 @@ private static AssistantActivity instance;
|
|||
saveCreatedAccount(username, password, displayName, null, domain, transport);
|
||||
}
|
||||
|
||||
public void loadLinphoneConfig(){
|
||||
//LinphoneManager.getInstance().loadConfig();
|
||||
//LinphoneManager.getInstance().restartLinphoneCore();
|
||||
}
|
||||
|
||||
private void launchDownloadCodec() {
|
||||
OpenH264DownloadHelper downloadHelper = LinphoneCoreFactory.instance().createOpenH264DownloadHelper();
|
||||
if (Version.getCpuAbis().contains("armeabi-v7a") && !Version.getCpuAbis().contains("x86") && !downloadHelper.isCodecFound()) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.linphone.assistant;
|
||||
/*
|
||||
CreateAccountActivationFragment.java
|
||||
CreateAccountCodeActivationFragment.java
|
||||
Copyright (C) 2015 Belledonne Communications, Grenoble, France
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
|
@ -42,9 +42,6 @@ import org.linphone.core.LinphoneXmlRpcSession;
|
|||
import org.linphone.core.LinphoneXmlRpcSessionImpl;
|
||||
import org.linphone.mediastream.Log;
|
||||
|
||||
/**
|
||||
* @author Sylvain Berfini
|
||||
*/
|
||||
public class CreateAccountCodeActivationFragment extends Fragment {
|
||||
private String username, phone, ha1;
|
||||
private EditText code;
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.linphone.core.LinphoneXmlRpcRequestImpl;
|
|||
import org.linphone.core.LinphoneXmlRpcSession;
|
||||
import org.linphone.core.LinphoneXmlRpcSessionImpl;
|
||||
import org.linphone.xmlrpc.XmlRpcHelper;
|
||||
import org.linphone.mediastream.Log;
|
||||
|
||||
import android.Manifest;
|
||||
import android.accounts.Account;
|
||||
|
@ -83,8 +82,11 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
|||
private LinphoneAccountCreator accountCreator;
|
||||
|
||||
private String getUsername() {
|
||||
String username = usernameEdit.getText().toString();
|
||||
return username.toLowerCase(Locale.getDefault());
|
||||
if(usernameEdit != null) {
|
||||
String username = usernameEdit.getText().toString();
|
||||
return username.toLowerCase(Locale.getDefault());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getPhoneNumber(){
|
||||
|
@ -134,27 +136,8 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
|||
|
||||
usernameError = (TextView) view.findViewById(R.id.username_error);
|
||||
usernameEdit = (EditText) view.findViewById(R.id.username);
|
||||
usernameEdit.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
/*if(useUsername.isChecked() && usernameEdit.getText().length() > 0) {
|
||||
sipUri.setText("Sip uri is sip:" + s.toString() + "@sip.linphone.org");
|
||||
} else {
|
||||
if(phoneNumberEdit.getText().length() > 0){
|
||||
sipUri.setText("Sip uri is sip:" + phoneNumberEdit.getText().toString()+ "@sip.linphone.org");
|
||||
} else {
|
||||
sipUri.setText("");
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {}
|
||||
});
|
||||
usernameLayout = (LinearLayout) view.findViewById(R.id.username_layout);
|
||||
|
||||
addUsernameHandler(usernameEdit, null);
|
||||
}
|
||||
|
||||
|
@ -177,7 +160,7 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
|||
addXMLRPCConfirmPasswordHandler(passwordEdit, passwordConfirmEdit, null);
|
||||
addXMLRPCEmailHandler(emailEdit, null);
|
||||
|
||||
if (getResources().getBoolean(R.bool.pre_fill_email_in_wizard)) {
|
||||
if (getResources().getBoolean(R.bool.pre_fill_email_in_assistant)) {
|
||||
Account[] accounts = AccountManager.get(getActivity()).getAccountsByType("com.google");
|
||||
|
||||
for (Account account: accounts) {
|
||||
|
@ -199,7 +182,7 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
|||
updateApplyButton();
|
||||
|
||||
createAccount = (Button) view.findViewById(R.id.assistant_create);
|
||||
createAccount.setEnabled(true);
|
||||
createAccount.setEnabled(false);
|
||||
createAccount.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
if(getResources().getBoolean(R.bool.isTablet)) {
|
||||
|
@ -207,7 +190,11 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
|||
createAccountWithEmail(getUsername(), passwordEdit.getText().toString(), emailEdit.getText().toString(), false);
|
||||
}
|
||||
} else {
|
||||
createAccountWithPhoneNumber(getUsername(), "", getPhoneNumber(), false);
|
||||
if(getResources().getBoolean(R.bool.assistant_allow_username)){
|
||||
createAccountWithPhoneNumber(getUsername(), "", getPhoneNumber(), false);
|
||||
} else {
|
||||
createAccountWithPhoneNumber(getPhoneNumber(), "", getPhoneNumber(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -292,7 +279,7 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
|||
}
|
||||
|
||||
private boolean isUsernameCorrect(String username) {
|
||||
if (getResources().getBoolean(R.bool.allow_only_phone_numbers_in_wizard)) {
|
||||
if (getResources().getBoolean(R.bool.allow_only_phone_numbers_in_assistant)) {
|
||||
LinphoneProxyConfig lpc = LinphoneManager.getLc().createProxyConfig();
|
||||
return lpc.isPhoneNumber(username);
|
||||
} else {
|
||||
|
@ -439,7 +426,6 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
|||
public void afterTextChanged(Editable s) {
|
||||
if (s.length() > 0) {
|
||||
phoneNumberOk = false;
|
||||
String phoneNumber = getPhoneNumber();
|
||||
String countryCode = dialCode.getText().toString();
|
||||
if(countryCode != null && countryCode.startsWith("+")) {
|
||||
countryCode = countryCode.substring(1);
|
||||
|
@ -639,7 +625,7 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
|||
|
||||
@Override
|
||||
public void onAccountCreatorIsAccountUsed(LinphoneAccountCreator accountCreator, final Status status) {
|
||||
if(useUsername.isChecked()){
|
||||
if(getResources().getBoolean(R.bool.assistant_allow_username) && useUsername.isChecked()){
|
||||
if (status.equals(Status.AccountNotExist)) {
|
||||
usernameOk = true;
|
||||
displayError(usernameOk, usernameError, usernameEdit, errorForStatus(status));
|
||||
|
@ -679,4 +665,9 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
|||
@Override
|
||||
public void onAccountCreatorIsAccountActivated(LinphoneAccountCreator accountCreator, Status status) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccountCreatorPhoneAccountRecovered(LinphoneAccountCreator accountCreator, Status status) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ public class LinphoneLoginFragment extends Fragment implements OnClickListener,
|
|||
return;
|
||||
}
|
||||
|
||||
AssistantActivity.instance().linphoneLogIn(login.getText().toString(), password.getText().toString(), displayName.getText().toString(), getResources().getBoolean(R.bool.setup_account_validation_mandatory));
|
||||
AssistantActivity.instance().linphoneLogIn(login.getText().toString(), password.getText().toString(), displayName.getText().toString(), getResources().getBoolean(R.bool.assistant_account_validation_mandatory));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -42,21 +42,21 @@ public class WelcomeFragment extends Fragment implements OnClickListener {
|
|||
createAccount.setOnClickListener(this);
|
||||
|
||||
logLinphoneAccount = (Button) view.findViewById(R.id.login_linphone);
|
||||
if (getResources().getBoolean(R.bool.hide_linphone_accounts_wizard)) {
|
||||
if (getResources().getBoolean(R.bool.hide_linphone_accounts_in_assistant)) {
|
||||
logLinphoneAccount.setVisibility(View.GONE);
|
||||
} else {
|
||||
logLinphoneAccount.setOnClickListener(this);
|
||||
}
|
||||
|
||||
logGenericAccount = (Button) view.findViewById(R.id.login_generic);
|
||||
if (getResources().getBoolean(R.bool.hide_generic_accounts_wizard)) {
|
||||
if (getResources().getBoolean(R.bool.hide_generic_accounts_in_assistant)) {
|
||||
logGenericAccount.setVisibility(View.GONE);
|
||||
} else {
|
||||
logGenericAccount.setOnClickListener(this);
|
||||
}
|
||||
|
||||
remoteProvisioning = (Button) view.findViewById(R.id.remote_provisioning);
|
||||
if (getResources().getBoolean(R.bool.hide_remote_provisioning_in_wizard)) {
|
||||
if (getResources().getBoolean(R.bool.hide_remote_provisioning_in_assistant)) {
|
||||
remoteProvisioning.setVisibility(View.GONE);
|
||||
} else {
|
||||
remoteProvisioning.setOnClickListener(this);
|
||||
|
|
|
@ -36,6 +36,7 @@ import android.os.Handler;
|
|||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
|
@ -45,6 +46,7 @@ public class InAppPurchaseActivity extends Activity implements InAppPurchaseList
|
|||
private static InAppPurchaseActivity instance;
|
||||
private InAppPurchaseHelper inAppPurchaseHelper;
|
||||
private ImageView cancel, back;
|
||||
private ProgressBar inProgress;
|
||||
|
||||
private List<Purchasable> purchasedItems;
|
||||
private Fragment fragment;
|
||||
|
@ -57,6 +59,9 @@ public class InAppPurchaseActivity extends Activity implements InAppPurchaseList
|
|||
inAppPurchaseHelper = new InAppPurchaseHelper(this, this);
|
||||
setContentView(R.layout.in_app);
|
||||
|
||||
inProgress = (ProgressBar) findViewById(R.id.purchaseItemsFetchInProgress);
|
||||
inProgress.setVisibility(View.VISIBLE);
|
||||
|
||||
back = (ImageView) findViewById(R.id.back);
|
||||
back.setOnClickListener(this);
|
||||
back.setVisibility(View.INVISIBLE);
|
||||
|
@ -77,7 +82,7 @@ public class InAppPurchaseActivity extends Activity implements InAppPurchaseList
|
|||
changeFragment(fragment);
|
||||
}
|
||||
|
||||
public void displayStore(Purchasable item) {
|
||||
public void displayPurchase(Purchasable item) {
|
||||
Bundle extra = new Bundle();
|
||||
extra.putString("item_id",item.getId());
|
||||
fragment = new InAppPurchaseFragment();
|
||||
|
@ -136,7 +141,7 @@ public class InAppPurchaseActivity extends Activity implements InAppPurchaseList
|
|||
@Override
|
||||
public void onAvailableItemsForPurchaseQueryFinished(ArrayList<Purchasable> items) {
|
||||
//purchasableItemsLayout.removeAllViews();
|
||||
|
||||
inProgress.setVisibility(View.GONE);
|
||||
purchasedItems = new ArrayList<Purchasable>();
|
||||
for (Purchasable item : items) {
|
||||
purchasedItems.add(item);
|
||||
|
@ -200,6 +205,7 @@ public class InAppPurchaseActivity extends Activity implements InAppPurchaseList
|
|||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
inProgress.setVisibility(View.GONE);
|
||||
Toast.makeText(InAppPurchaseActivity.this, error, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -23,11 +23,13 @@ import android.os.Bundle;
|
|||
import android.os.Handler;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Patterns;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.linphone.LinphoneManager;
|
||||
|
@ -39,15 +41,17 @@ import org.linphone.xmlrpc.XmlRpcHelper;
|
|||
import org.linphone.xmlrpc.XmlRpcListenerBase;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
public class InAppPurchaseFragment extends Fragment implements View.OnClickListener {
|
||||
|
||||
private LinearLayout usernameLayout;
|
||||
private EditText username, email;
|
||||
private TextView errorMessage;
|
||||
|
||||
private boolean usernameOk = false;
|
||||
private boolean usernameOk = false, emailOk = false;
|
||||
private Handler mHandler = new Handler();
|
||||
private String defaultUsername, defaultEmail;
|
||||
private Button buyItemButton, recoverAccountButton;
|
||||
|
||||
@Override
|
||||
|
@ -61,19 +65,36 @@ public class InAppPurchaseFragment extends Fragment implements View.OnClickListe
|
|||
|
||||
String id = getArguments().getString("item_id");
|
||||
Purchasable item = InAppPurchaseActivity.instance().getPurchasedItem(id);
|
||||
|
||||
Log.w("Item store " + item.getDescription());
|
||||
|
||||
buyItemButton = (Button) view.findViewById(R.id.inapp_button);
|
||||
|
||||
displayBuySubscriptionButton(item);
|
||||
|
||||
defaultEmail = InAppPurchaseActivity.instance().getGmailAccount();
|
||||
defaultUsername = LinphonePreferences.instance().getAccountUsername(LinphonePreferences.instance().getDefaultAccountIndex());
|
||||
|
||||
usernameLayout = (LinearLayout) view.findViewById(R.id.username_layout);
|
||||
username = (EditText) view.findViewById(R.id.username);
|
||||
username.setText(LinphonePreferences.instance().getAccountUsername(0));
|
||||
if(!getResources().getBoolean(R.bool.hide_username_in_inapp)){
|
||||
usernameLayout.setVisibility(View.VISIBLE);
|
||||
username.setText(LinphonePreferences.instance().getAccountUsername(LinphonePreferences.instance().getDefaultAccountIndex()));
|
||||
|
||||
addUsernameHandler(username, errorMessage);
|
||||
} else {
|
||||
if(defaultUsername != null){
|
||||
usernameLayout.setVisibility(View.GONE);
|
||||
usernameOk = true;
|
||||
}
|
||||
}
|
||||
|
||||
email = (EditText) view.findViewById(R.id.email);
|
||||
email.setText(InAppPurchaseActivity.instance().getGmailAccount());
|
||||
if(defaultEmail != null){
|
||||
email.setText(defaultEmail);
|
||||
emailOk = true;
|
||||
}
|
||||
|
||||
buyItemButton.setEnabled(emailOk && usernameOk);
|
||||
errorMessage = (TextView) view.findViewById(R.id.username_error);
|
||||
addUsernameHandler(username, errorMessage);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -102,6 +123,36 @@ public class InAppPurchaseFragment extends Fragment implements View.OnClickListe
|
|||
});
|
||||
}
|
||||
|
||||
private void addEmailHandler(final EditText field, final TextView errorMessage) {
|
||||
field.addTextChangedListener(new TextWatcher() {
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
public void onTextChanged(CharSequence s, int start, int count, int after) {
|
||||
emailOk = false;
|
||||
String email = s.toString();
|
||||
if (isEmailCorrect(email)) {
|
||||
emailOk = true;
|
||||
errorMessage.setText("");
|
||||
} else {
|
||||
errorMessage.setText(R.string.wizard_email_incorrect);
|
||||
}
|
||||
if (buyItemButton != null) buyItemButton.setEnabled(emailOk && usernameOk);
|
||||
if (recoverAccountButton != null) recoverAccountButton.setEnabled(emailOk && usernameOk);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isEmailCorrect(String email) {
|
||||
Pattern emailPattern = Patterns.EMAIL_ADDRESS;
|
||||
return emailPattern.matcher(email).matches();
|
||||
}
|
||||
|
||||
|
||||
private boolean isUsernameCorrect(String username) {
|
||||
LinphoneProxyConfig lpc = LinphoneManager.getLc().createProxyConfig();
|
||||
|
@ -109,33 +160,17 @@ public class InAppPurchaseFragment extends Fragment implements View.OnClickListe
|
|||
}
|
||||
|
||||
private void displayBuySubscriptionButton(Purchasable item) {
|
||||
//View layout = LayoutInflater.from(this).inflate(R.layout.in_app_purchasable, purchasableItemsLayout);
|
||||
//Button button = (Button) layout.findViewById(R.id.inapp_button);
|
||||
buyItemButton.setText("Buy account (" + item.getPrice() + ")");
|
||||
buyItemButton.setTag(item);
|
||||
buyItemButton.setOnClickListener(this);
|
||||
/*XmlRpcHelper xmlRpcHelper = new XmlRpcHelper();
|
||||
xmlRpcHelper.createAccountAsync(new XmlRpcListenerBase() {
|
||||
@Override
|
||||
public void onAccountCreated(String result) {
|
||||
//TODO
|
||||
}
|
||||
}, getUsername(), email.getText().toString(), null);*/
|
||||
|
||||
buyItemButton.setEnabled(usernameOk);
|
||||
buyItemButton.setEnabled(usernameOk && emailOk);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Purchasable item = (Purchasable) v.getTag();
|
||||
if (v.equals(recoverAccountButton)) {
|
||||
//XmlRpcHelper xmlRpcHelper = new XmlRpcHelper();
|
||||
/*xmlRpcHelper.createAccountAsync(new XmlRpcListenerBase() {
|
||||
@Override
|
||||
public void onAccountCreated(String result) {
|
||||
//TODO
|
||||
}
|
||||
}, getUsername(), email.getText().toString(), null);*/
|
||||
//TODO
|
||||
} else {
|
||||
InAppPurchaseActivity.instance().buyInapp(getUsername(), item);
|
||||
}
|
||||
|
|
|
@ -95,6 +95,6 @@ public class InAppPurchaseListFragment extends Fragment implements AdapterView.O
|
|||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
Purchasable item = (Purchasable) view.getTag();
|
||||
InAppPurchaseActivity.instance().displayStore(item);
|
||||
InAppPurchaseActivity.instance().displayPurchase(item);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue