Improved dialogs

This commit is contained in:
Sylvain Berfini 2018-11-06 12:01:05 +01:00
parent 6388141572
commit 9cd759b5cf
9 changed files with 123 additions and 156 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 391 B

View file

@ -32,17 +32,6 @@
android:src="@drawable/event_gray"
android:scaleType="fitXY"/>
<!--<TextView
android:id="@+id/event_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="italic"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" - "/>-->
<TextView
android:id="@+id/event_text"
android:layout_width="wrap_content"

View file

@ -1,47 +1,107 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center">
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:id="@+id/customText"
style="@style/font14"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="20dp"/>
<ImageView
android:id="@+id/icon"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/security_alert_indicator"
android:layout_margin="15dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="@+id/customText"
style="@style/font14"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Lorem ipsum dolor sit amet"
android:gravity="center"
android:textAlignment="center"
android:layout_margin="15dp"/>
<Button
android:id="@+id/cancel"
android:text="@string/cancel"
android:background="@drawable/resizable_cancel_button"
style="@style/font8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:padding="10dp"/>
<EditText
android:id="@+id/password"
android:visibility="gone"
android:background="@drawable/resizable_textfield"
android:textColor="@color/colorB"
android:inputType="textPassword"
android:hint="@string/password"
android:textCursorDrawable="@null"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_margin="15dp"
android:maxLines="1"/>
<Button
android:id="@+id/delete_button"
android:text="@string/delete"
android:background="@drawable/resizable_confirm_delete_button"
style="@style/font15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:padding="10dp"/>
<LinearLayout
android:id="@+id/doNotAskAgainLayout"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal"
android:layout_margin="5dp">
</LinearLayout>
<CheckBox
android:id="@+id/doNotAskAgain"
android:button="@drawable/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/doNotAskAgainLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/font14"
android:layout_marginLeft="10dp"
android:text="@string/do_not_ask_again"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal"
android:layout_margin="15dp">
<Button
android:id="@+id/cancel"
android:text="@string/cancel"
android:background="@drawable/resizable_assistant_button"
style="@style/font8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:padding="10dp"/>
<Button
android:id="@+id/delete_button"
android:text="@string/delete"
android:background="@drawable/resizable_assistant_button"
android:backgroundTint="@color/colorI"
style="@style/font15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:padding="10dp"/>
<Button
android:id="@+id/ok_button"
android:visibility="gone"
android:text="@string/ok"
android:background="@drawable/resizable_assistant_button"
android:backgroundTint="@color/colorL"
style="@style/font15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:padding="10dp"/>
</LinearLayout>
</LinearLayout>

View file

@ -1,59 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center">
<TextView
android:id="@+id/customText"
style="@style/font14"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="20dp"/>
<EditText
android:id="@+id/password"
android:background="@drawable/resizable_textfield"
android:textColor="@color/colorB"
android:inputType="textPassword"
android:hint="@string/password"
android:textCursorDrawable="@null"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_margin="20dp"
android:maxLines="1"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal">
<Button
android:id="@+id/cancel"
android:text="@string/cancel"
android:background="@drawable/resizable_cancel_button"
style="@style/font8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:padding="10dp"/>
<Button
android:id="@+id/retry"
android:text="@string/retry"
android:background="@drawable/resizable_confirm_delete_button"
style="@style/font15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:padding="10dp"/>
</LinearLayout>
</LinearLayout>

View file

@ -1,43 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toastRoot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/colorB"
android:orientation="vertical" >
<TextView
android:id="@+id/toastMessage"
android:textColor="@android:color/black"
android:layout_marginTop="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/toastNotOK"
android:src="@drawable/security_pending"
android:layout_weight="1"
android:layout_marginTop="10dp"
android:layout_gravity="center_horizontal"
android:adjustViewBounds="true"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ImageView
android:id="@+id/toastOK"
android:src="@drawable/security_ok"
android:layout_weight="1"
android:layout_marginTop="10dp"
android:layout_gravity="center_horizontal"
android:adjustViewBounds="true"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>

View file

@ -52,6 +52,7 @@
<string name="yes">Yes</string>
<string name="link_account">Link your account</string>
<string name="update_available">An update is available</string>
<string name="do_not_ask_again">Do not ask again</string>
<!-- Launch screen -->
<string name="app_description">the <i>libre</i> SIP client</string>

View file

@ -51,6 +51,7 @@ import android.provider.Settings.SettingNotFoundException;
import android.telephony.TelephonyManager;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.Toast;
import org.linphone.activities.LinphoneActivity;
@ -1519,18 +1520,31 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
}
private void askLinkWithPhoneNumber() {
if (!LinphonePreferences.instance().isLinkPopupEnabled()) return;
long now = new Timestamp(new Date().getTime()).getTime();
if (LinphonePreferences.instance().getLinkPopupTime() != null && Long.parseLong(LinphonePreferences.instance().getLinkPopupTime()) >= now) return;
long future = new Timestamp(LinphoneActivity.instance().getResources().getInteger(R.integer.popup_time_interval)).getTime();
long newDate = now + future;
LinphonePreferences.instance().setLinkPopupTime(String.valueOf(newDate));
final Dialog dialog = LinphoneActivity.instance().displayDialog(String.format(getString(R.string.link_account_popup), LinphoneManager.getLc().getDefaultProxyConfig().getIdentityAddress().asStringUriOnly()));
Button delete = (Button) dialog.findViewById(R.id.delete_button);
Button delete = dialog.findViewById(R.id.delete_button);
delete.setText(getString(R.string.link));
Button cancel = (Button) dialog.findViewById(R.id.cancel);
Button cancel = dialog.findViewById(R.id.cancel);
cancel.setText(getString(R.string.maybe_later));
dialog.findViewById(R.id.doNotAskAgainLayout).setVisibility(View.VISIBLE);
final CheckBox doNotAskAgain = dialog.findViewById(R.id.doNotAskAgain);
dialog.findViewById(R.id.doNotAskAgainLabel).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
doNotAskAgain.setChecked(!doNotAskAgain.isChecked());
}
});
delete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@ -1543,11 +1557,12 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
}
});
LinphonePreferences.instance().setLinkPopupTime(String.valueOf(newDate));
cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (doNotAskAgain.isChecked()) {
LinphonePreferences.instance().enableLinkPopup(false);
}
dialog.dismiss();
}
});

View file

@ -1532,8 +1532,12 @@ public class LinphonePreferences {
return getConfig().getString("app", "link_popup_time", null);
}
public String getXmlRpcServerUrl() {
return getConfig().getString("app", "server_url", null);
public boolean isLinkPopupEnabled() {
return getConfig().getBool("app", "link_popup_enabled", true);
}
public void enableLinkPopup(boolean enable) {
getConfig().setBool("app", "link_popup_enabled", enable);
}
public String getDebugPopupAddress() {

View file

@ -993,7 +993,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
dialog.getWindow().setBackgroundDrawable(d);
TextView customText = (TextView) dialog.findViewById(R.id.customText);
TextView customText = dialog.findViewById(R.id.customText);
customText.setText(text);
return dialog;
}