Update in_app ui

[--force]
This commit is contained in:
Margaux Clerc 2016-06-28 16:08:25 +02:00
parent 0da687df64
commit 9143a61ad0
8 changed files with 118 additions and 107 deletions

View file

@ -5,26 +5,15 @@
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
<Button
android:id="@+id/inapp_button"
android:text="@string/assistant_create_account"
android:background="@drawable/assistant_button"
style="@style/font8"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
<TextView
android:id="@+id/text"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/black"/>
</RelativeLayout>
android:paddingRight="10dp"
android:layout_width="match_parent"
android:layout_height="40dp"/>
</LinearLayout>

View file

@ -1,78 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@color/colorH"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:paddingTop="40dp"
android:textSize="20sp"
android:textStyle="bold"
android:textColor="@android:color/black"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/assistant"/>
<TextView
android:paddingTop="10dp"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/setup_error"
android:textColor="#ffff0000"/>
<LinearLayout
android:id="@+id/topbar"
android:background="@color/colorF"
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="60dp">
<TextView
android:text="@string/assistant"
style="@style/font1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="40dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:padding="30dp"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/username_label"
android:text="@string/username"
style="@style/font13"
android:textAllCaps="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/username"
android:background="@drawable/resizable_textfield"
android:textColor="@color/colorB"
android:contentDescription="@string/content_description_username_field"
android:inputType="text|textEmailAddress"
android:layout_width="match_parent"
android:layout_height="40dp"
android:singleLine="true"/>
<TextView
android:id="@+id/username_error"
android:text="@string/error"
style="@style/font20"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="invisible"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:textCursorDrawable="@null"
android:id="@+id/setup_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/username"
android:inputType="phone"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true"
android:textColor="@android:color/black" />
<ImageView
android:id="@+id/setup_username_ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="5dp"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:textCursorDrawable="@null"
android:id="@+id/setup_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/email"
android:inputType="textEmailAddress"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true"
android:textColor="@android:color/black" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/email_label"
android:text="@string/email"
style="@style/font13"
android:textAllCaps="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/email"
android:background="@drawable/resizable_textfield"
android:textColor="@color/colorB"
android:inputType="text|textEmailAddress"
android:contentDescription="@string/content_description_email_field"
android:textCursorDrawable="@null"
android:layout_width="match_parent"
android:layout_height="40dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true"/>
</LinearLayout>
<LinearLayout
android:id="@+id/purchasable_items"

View file

@ -14,6 +14,7 @@
<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>
<string name="wizard_url">https://www.linphone.org/wizard.php</string>

View file

@ -34,6 +34,7 @@
<string name="pref_sipaccounts_key">pref_sipaccounts_key</string>
<string name="setup_key">setup_key</string>
<string name="pref_add_account_key">pref_add_account_key</string>
<string name="pref_in_app_store_key">pref_in_app_store_key</string>
<string name="pref_video_key">pref_video_key</string>
<string name="pref_video_codecs_key">pref_video_codecs_key</string>

View file

@ -219,6 +219,7 @@
<string name="pref_sipaccounts">SIP Accounts</string>
<string name="default_account_flag">Default account</string>
<string name="pref_add_account">Add account</string>
<string name="pref_in_app_store">In-app Store</string>
<string name="pref_tunnel">Tunnel</string>
<string name="pref_tunnel_host">Hostname</string>
<string name="pref_tunnel_port">Port</string>

View file

@ -10,8 +10,8 @@
android:key="@string/pref_add_account_key"/>
<Preference
android:title="In-app Store"
android:key="in_app_store"/>
android:title="@string/pref_in_app_store"
android:key="@string/pref_in_app_store_key"/>
<PreferenceCategory
android:title="@string/pref_tunnel"

View file

@ -116,7 +116,7 @@ public class SettingsFragment extends PreferencesListFragment {
return true;
}
});
findPreference("in_app_store").setOnPreferenceClickListener(new OnPreferenceClickListener() {
findPreference(getString(R.string.pref_in_app_store_key)).setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent intent = new Intent(LinphoneService.instance(), InAppPurchaseActivity.class);
@ -146,6 +146,11 @@ public class SettingsFragment extends PreferencesListFragment {
hidePreference(R.string.pref_add_account_key);
}
if(!getResources().getBoolean(R.bool.in_app_purchase_in_settings)){
hidePreference(R.string.pref_in_app_store_key);
}
if (getResources().getBoolean(R.bool.disable_animations)) {
uncheckAndHidePreference(R.string.pref_animation_enable_key);
}

View file

@ -37,6 +37,7 @@ import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
@ -50,7 +51,7 @@ public class InAppPurchaseActivity extends Activity implements InAppPurchaseList
private InAppPurchaseHelper inAppPurchaseHelper;
private LinearLayout purchasableItemsLayout;
private ArrayList<Purchasable> purchasedItems;
private ImageView buyItemButton, recoverAccountButton;
private Button buyItemButton, recoverAccountButton;
private Handler mHandler = new Handler();
private EditText username, email;
@ -66,11 +67,10 @@ public class InAppPurchaseActivity extends Activity implements InAppPurchaseList
setContentView(R.layout.in_app_store);
purchasableItemsLayout = (LinearLayout) findViewById(R.id.purchasable_items);
username = (EditText) findViewById(R.id.setup_username);
email = (EditText) findViewById(R.id.setup_email);
ImageView usernameOkIV = (ImageView) findViewById(R.id.setup_username_ok);
addUsernameHandler(username, usernameOkIV);
errorMessage = (TextView) findViewById(R.id.setup_error);
username = (EditText) findViewById(R.id.username);
email = (EditText) findViewById(R.id.email);
errorMessage = (TextView) findViewById(R.id.username_error);
addUsernameHandler(username, errorMessage);
}
@Override
@ -174,11 +174,11 @@ public class InAppPurchaseActivity extends Activity implements InAppPurchaseList
private void displayBuySubscriptionButton(Purchasable item) {
View layout = LayoutInflater.from(this).inflate(R.layout.in_app_purchasable, purchasableItemsLayout);
TextView text = (TextView) layout.findViewById(R.id.text);
text.setText("Buy account (" + item.getPrice() + ")");
ImageView image = (ImageView) layout.findViewById(R.id.image);
image.setTag(item);
image.setOnClickListener(this);XmlRpcHelper xmlRpcHelper = new XmlRpcHelper();
Button button = (Button) layout.findViewById(R.id.inapp_button);
button.setText("Buy account (" + item.getPrice() + ")");
button.setTag(item);
button.setOnClickListener(this);
XmlRpcHelper xmlRpcHelper = new XmlRpcHelper();
xmlRpcHelper.createAccountAsync(new XmlRpcListenerBase() {
@Override
public void onAccountCreated(String result) {
@ -186,19 +186,18 @@ public class InAppPurchaseActivity extends Activity implements InAppPurchaseList
}
}, getUsername(), email.getText().toString(), null);
buyItemButton = image;
buyItemButton = button;
buyItemButton.setEnabled(usernameOk);
}
private void displayRecoverAccountButton(Purchasable item) {
View layout = LayoutInflater.from(this).inflate(R.layout.in_app_purchasable, purchasableItemsLayout);
TextView text = (TextView) layout.findViewById(R.id.text);
text.setText("Recover account");
ImageView image = (ImageView) layout.findViewById(R.id.image);
image.setTag(item);
image.setOnClickListener(this);
Button button = (Button) layout.findViewById(R.id.inapp_button);
button.setText("Recover account");
button.setTag(item);
button.setOnClickListener(this);
recoverAccountButton = image;
recoverAccountButton = button;
recoverAccountButton.setEnabled(usernameOk);
}
@ -214,7 +213,7 @@ public class InAppPurchaseActivity extends Activity implements InAppPurchaseList
return lpc.isPhoneNumber(username);
}
private void addUsernameHandler(final EditText field, final ImageView icon) {
private void addUsernameHandler(final EditText field, final TextView errorMessage) {
field.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
@ -229,11 +228,9 @@ public class InAppPurchaseActivity extends Activity implements InAppPurchaseList
String username = s.toString();
if (isUsernameCorrect(username)) {
usernameOk = true;
//icon.setImageResource(R.drawable.wizard_ok);
errorMessage.setText("");
} else {
errorMessage.setText(R.string.wizard_username_incorrect);
//icon.setImageResource(R.drawable.wizard_notok);
}
if (buyItemButton != null) buyItemButton.setEnabled(usernameOk);
if (recoverAccountButton != null) recoverAccountButton.setEnabled(usernameOk);