mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
remove outdated reminder
the warning about outdated apps was pretty unreliable in the past - because of too short timings and also because of the "installation date" and the fact that an "installer" was used, is not always reliable. also, the "installer date" could be wrong - if the installation was done when the clock was altered badly. as we cannot rely on the things the system provides here, we move the whole thing to the core at https://github.com/deltachat/deltachat-core-rust/pull/1901 which has also the advantage that this is done for all uis then.
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true" android:drawable="@color/core_red_highlight" />
|
||||
<item android:state_focused="true" android:drawable="@color/core_red_highlight" />
|
||||
<item android:drawable="@color/core_red" />
|
||||
</selector>
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true" android:drawable="@color/delta_primary" />
|
||||
<item android:state_focused="true" android:drawable="@color/delta_primary" />
|
||||
<item android:drawable="@color/delta_primary_dark" />
|
||||
</selector>
|
||||
@@ -30,13 +30,6 @@
|
||||
android:clipToPadding="false"
|
||||
android:clipChildren="false">
|
||||
|
||||
<ViewStub
|
||||
android:id="@+id/reminder_stub"
|
||||
android:layout="@layout/conversation_activity_reminderview_stub"
|
||||
android:inflatedId="@+id/reminder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<FrameLayout android:id="@+id/fragment_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
@@ -61,4 +54,4 @@
|
||||
</LinearLayout>
|
||||
</org.thoughtcrime.securesms.components.camera.QuickAttachmentDrawer>
|
||||
</org.thoughtcrime.securesms.components.InputAwareLayout>
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<org.thoughtcrime.securesms.components.reminder.ReminderView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/reminder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
@@ -51,11 +51,6 @@
|
||||
android:orientation="vertical"
|
||||
tools:visibility="gone">
|
||||
|
||||
<org.thoughtcrime.securesms.components.reminder.ReminderView
|
||||
android:id="@+id/reminder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/list"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/reminder_background_normal"
|
||||
android:focusable="true"
|
||||
android:nextFocusRight="@+id/cancel"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/reminder"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_margin="16dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/reminder_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="18sp"
|
||||
tools:text="Invite to Signal"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/reminder_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="sans-serif-light"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp"
|
||||
tools:text="Take your conversation with Jules Bonnot to the next level."/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/cancel"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:focusable="true"
|
||||
android:nextFocusLeft="@+id/container"
|
||||
android:nextFocusRight="@+id/container"
|
||||
android:src="@drawable/ic_close_white_24dp"
|
||||
android:contentDescription="@string/cancel"/>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -103,8 +103,6 @@
|
||||
<attr name="import_export_item_background_shadow_color" format="reference|color" />
|
||||
<attr name="import_export_item_card_background" format="reference" />
|
||||
|
||||
<attr name="reminder_header_background" format="color"/>
|
||||
|
||||
<attr name="menu_new_conversation_icon" format="reference" />
|
||||
<attr name="menu_search_icon" format="reference" />
|
||||
<attr name="menu_popup_expand" format="reference"/>
|
||||
|
||||
@@ -247,10 +247,6 @@
|
||||
<string name="ask_start_chat_with">Chat with %1$s?</string>
|
||||
<!-- Translators: %1$s will be replaces by a comma separated list of names -->
|
||||
<string name="ask_remove_members">Remove %1$s from group?</string>
|
||||
<string name="info_outdated_app_title">Your app version is outdated</string>
|
||||
<string name="info_outdated_app_text">It seems that you installed Delta Chat from a source without auto updates (e.g. GitHub). Please switch to a store version to receive the latest features and bug fixes.</string>
|
||||
<string name="info_outdated_app_dialog_title">Update sources</string>
|
||||
<string name="info_outdated_app_dialog_text">Delta Chat is available on:</string>
|
||||
|
||||
|
||||
<!-- contact list -->
|
||||
|
||||
@@ -174,8 +174,6 @@
|
||||
<item name="menu_save_icon">@drawable/ic_save_white_24dp</item>
|
||||
<item name="menu_reply_icon">@drawable/ic_reply_white_24dp</item>
|
||||
|
||||
<item name="reminder_header_background">#ff1d85d7</item>
|
||||
|
||||
<item name="pref_icon_tint">@color/delta_primary_dark</item>
|
||||
<item name="icon_tint">@color/grey_700</item>
|
||||
<item name="icon_tint_dark">@color/grey_100</item>
|
||||
@@ -321,8 +319,6 @@
|
||||
<item name="menu_save_icon">@drawable/ic_save_white_24dp</item>
|
||||
<item name="menu_reply_icon">@drawable/ic_reply_white_24dp</item>
|
||||
|
||||
<item name="reminder_header_background">@color/delta_primary_dark</item>
|
||||
|
||||
<item name="pref_icon_tint">@color/core_white</item>
|
||||
<item name="icon_tint">@color/grey_100</item>
|
||||
<item name="icon_tint_dark">?icon_tint</item>
|
||||
|
||||
@@ -83,7 +83,6 @@ import org.thoughtcrime.securesms.components.camera.QuickAttachmentDrawer.Attach
|
||||
import org.thoughtcrime.securesms.components.camera.QuickAttachmentDrawer.DrawerState;
|
||||
import org.thoughtcrime.securesms.components.emoji.EmojiKeyboardProvider;
|
||||
import org.thoughtcrime.securesms.components.emoji.MediaKeyboard;
|
||||
import org.thoughtcrime.securesms.components.reminder.ReminderView;
|
||||
import org.thoughtcrime.securesms.connect.ApplicationDcContext;
|
||||
import org.thoughtcrime.securesms.connect.DcHelper;
|
||||
import org.thoughtcrime.securesms.map.MapActivity;
|
||||
@@ -174,7 +173,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
private ConversationFragment fragment;
|
||||
private InputAwareLayout container;
|
||||
private View composePanel;
|
||||
protected Stub<ReminderView> reminderView;
|
||||
private ScaleStableImageView backgroundView;
|
||||
|
||||
private AttachmentTypeSelector attachmentTypeSelector;
|
||||
@@ -833,7 +831,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
emojiDrawerStub = ViewUtil.findStubById(this, R.id.emoji_drawer_stub);
|
||||
composePanel = ViewUtil.findById(this, R.id.bottom_panel);
|
||||
container = ViewUtil.findById(this, R.id.layout_container);
|
||||
reminderView = ViewUtil.findStubById(this, R.id.reminder_stub);
|
||||
quickAttachmentDrawer = ViewUtil.findById(this, R.id.quick_attachment_drawer);
|
||||
quickAttachmentToggle = ViewUtil.findById(this, R.id.quick_attachment_toggle);
|
||||
inputPanel = ViewUtil.findById(this, R.id.bottom_panel);
|
||||
|
||||
@@ -58,9 +58,6 @@ import org.thoughtcrime.securesms.ConversationListAdapter.ItemClickListener;
|
||||
import org.thoughtcrime.securesms.components.recyclerview.DeleteItemAnimator;
|
||||
import org.thoughtcrime.securesms.components.registration.PulsingFloatingActionButton;
|
||||
import org.thoughtcrime.securesms.components.reminder.DozeReminder;
|
||||
import org.thoughtcrime.securesms.components.reminder.OutdatedReminder;
|
||||
import org.thoughtcrime.securesms.components.reminder.Reminder;
|
||||
import org.thoughtcrime.securesms.components.reminder.ReminderView;
|
||||
import org.thoughtcrime.securesms.connect.ApplicationDcContext;
|
||||
import org.thoughtcrime.securesms.connect.DcChatlistLoader;
|
||||
import org.thoughtcrime.securesms.connect.DcHelper;
|
||||
@@ -97,7 +94,6 @@ public class ConversationListFragment extends Fragment
|
||||
|
||||
private ActionMode actionMode;
|
||||
private RecyclerView list;
|
||||
private ReminderView reminderView;
|
||||
private View emptyState;
|
||||
private TextView emptySearch;
|
||||
private PulsingFloatingActionButton fab;
|
||||
@@ -132,7 +128,6 @@ public class ConversationListFragment extends Fragment
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle bundle) {
|
||||
final View view = inflater.inflate(R.layout.conversation_list_fragment, container, false);
|
||||
|
||||
reminderView = ViewUtil.findById(view, R.id.reminder);
|
||||
list = ViewUtil.findById(view, R.id.list);
|
||||
fab = ViewUtil.findById(view, R.id.fab);
|
||||
emptyState = ViewUtil.findById(view, R.id.empty_state);
|
||||
@@ -141,8 +136,6 @@ public class ConversationListFragment extends Fragment
|
||||
if (archive) fab.setVisibility(View.GONE);
|
||||
else fab.setVisibility(View.VISIBLE);
|
||||
|
||||
reminderView.setOnDismissListener(this::updateReminders);
|
||||
|
||||
list.setHasFixedSize(true);
|
||||
list.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
list.setItemAnimator(new DeleteItemAnimator());
|
||||
@@ -231,32 +224,23 @@ public class ConversationListFragment extends Fragment
|
||||
|
||||
@SuppressLint({"StaticFieldLeak", "NewApi"})
|
||||
private void updateReminders() {
|
||||
new AsyncTask<Context, Void, Optional<? extends Reminder>>() {
|
||||
new AsyncTask<Context, Void, Void>() {
|
||||
@Override
|
||||
protected Optional<? extends Reminder> doInBackground(Context... params) {
|
||||
protected Void doInBackground(Context... params) {
|
||||
final Context context = params[0];
|
||||
try {
|
||||
if (DozeReminder.isEligible(context)) {
|
||||
DozeReminder.addDozeReminderDeviceMsg(context);
|
||||
return Optional.absent();
|
||||
} else if (OutdatedReminder.isEligible(context)) {
|
||||
return Optional.of(new OutdatedReminder(context));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return Optional.absent();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Optional<? extends Reminder> reminder) {
|
||||
protected void onPostExecute(Void result) {
|
||||
DozeReminder.maybeAskDirectly(getActivity());
|
||||
if (reminder.isPresent() && getActivity() != null && !isRemoving()) {
|
||||
reminderView.showReminder(reminder.get());
|
||||
} else if (!reminder.isPresent()) {
|
||||
reminderView.hide();
|
||||
}
|
||||
}
|
||||
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, getActivity());
|
||||
}
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
package org.thoughtcrime.securesms.components.reminder;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import android.text.util.Linkify;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class OutdatedReminder extends Reminder {
|
||||
|
||||
private static final long OUTDATED_THRESHOLD_IN_DAYS = 90;
|
||||
|
||||
public OutdatedReminder(@NonNull final Context context) {
|
||||
super(context.getString(R.string.info_outdated_app_title),
|
||||
context.getString(R.string.info_outdated_app_text));
|
||||
|
||||
setOkListener(v -> {
|
||||
AlertDialog sourceDialog = new AlertDialog.Builder(context)
|
||||
.setTitle(R.string.info_outdated_app_dialog_title)
|
||||
.setMessage(context.getString(R.string.info_outdated_app_dialog_text)
|
||||
+"\n\nF-Droid: https://f-droid.org/packages/com.b44t.messenger"
|
||||
+"\n\nGoogle Play: https://play.google.com/store/apps/details?id=chat.delta")
|
||||
.setPositiveButton(R.string.ok, (dialog, which) -> dialog.cancel())
|
||||
.create();
|
||||
sourceDialog.show();
|
||||
Linkify.addLinks((TextView) Objects.requireNonNull(sourceDialog.findViewById(android.R.id.message)), Linkify.WEB_URLS);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDismissable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isEligible(Context context) {
|
||||
if (context == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
final PackageManager packageManager = context.getPackageManager();
|
||||
String packageName = context.getPackageName();
|
||||
if (packageManager.getInstallerPackageName(packageName) == null) {
|
||||
long lastUpdateTime = packageManager
|
||||
.getPackageInfo(packageName, 0)
|
||||
.lastUpdateTime;
|
||||
long nowTime = System.currentTimeMillis();
|
||||
long diff = nowTime - lastUpdateTime;
|
||||
long diffInDays = TimeUnit.MILLISECONDS.toDays(diff);
|
||||
return diffInDays >= OUTDATED_THRESHOLD_IN_DAYS;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package org.thoughtcrime.securesms.components.reminder;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import android.view.View.OnClickListener;
|
||||
|
||||
public abstract class Reminder {
|
||||
private CharSequence title;
|
||||
private CharSequence text;
|
||||
|
||||
private OnClickListener okListener;
|
||||
private OnClickListener dismissListener;
|
||||
|
||||
public Reminder(@Nullable CharSequence title,
|
||||
@NonNull CharSequence text)
|
||||
{
|
||||
this.title = title;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public @Nullable CharSequence getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public CharSequence getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public OnClickListener getOkListener() {
|
||||
return okListener;
|
||||
}
|
||||
|
||||
public OnClickListener getDismissListener() {
|
||||
return dismissListener;
|
||||
}
|
||||
|
||||
public void setOkListener(OnClickListener okListener) {
|
||||
this.okListener = okListener;
|
||||
}
|
||||
|
||||
public void setDismissListener(OnClickListener dismissListener) {
|
||||
this.dismissListener = dismissListener;
|
||||
}
|
||||
|
||||
public boolean isDismissable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public @NonNull Importance getImportance() {
|
||||
return Importance.NORMAL;
|
||||
}
|
||||
|
||||
|
||||
public enum Importance {
|
||||
NORMAL, ERROR
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
package org.thoughtcrime.securesms.components.reminder;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.os.Build.VERSION_CODES;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
|
||||
/**
|
||||
* View to display actionable reminders to the user
|
||||
*/
|
||||
public class ReminderView extends LinearLayout {
|
||||
private ViewGroup container;
|
||||
private ImageButton closeButton;
|
||||
private TextView title;
|
||||
private TextView text;
|
||||
private OnDismissListener dismissListener;
|
||||
|
||||
public ReminderView(Context context) {
|
||||
super(context);
|
||||
initialize();
|
||||
}
|
||||
|
||||
public ReminderView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
initialize();
|
||||
}
|
||||
|
||||
@TargetApi(VERSION_CODES.HONEYCOMB)
|
||||
public ReminderView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
initialize();
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
LayoutInflater.from(getContext()).inflate(R.layout.reminder_header, this, true);
|
||||
container = ViewUtil.findById(this, R.id.container);
|
||||
closeButton = ViewUtil.findById(this, R.id.cancel);
|
||||
title = ViewUtil.findById(this, R.id.reminder_title);
|
||||
text = ViewUtil.findById(this, R.id.reminder_text);
|
||||
}
|
||||
|
||||
public void showReminder(final Reminder reminder) {
|
||||
if (!TextUtils.isEmpty(reminder.getTitle())) {
|
||||
title.setText(reminder.getTitle());
|
||||
title.setVisibility(VISIBLE);
|
||||
} else {
|
||||
title.setText("");
|
||||
title.setVisibility(GONE);
|
||||
}
|
||||
text.setText(reminder.getText());
|
||||
container.setBackgroundResource(reminder.getImportance() == Reminder.Importance.ERROR ? R.drawable.reminder_background_error
|
||||
: R.drawable.reminder_background_normal);
|
||||
|
||||
setOnClickListener(reminder.getOkListener());
|
||||
|
||||
closeButton.setVisibility(reminder.isDismissable() ? View.VISIBLE : View.GONE);
|
||||
closeButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
hide();
|
||||
if (reminder.getDismissListener() != null) reminder.getDismissListener().onClick(v);
|
||||
if (dismissListener != null) dismissListener.onDismiss();
|
||||
}
|
||||
});
|
||||
|
||||
container.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
public void setOnDismissListener(OnDismissListener dismissListener) {
|
||||
this.dismissListener = dismissListener;
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
container.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public interface OnDismissListener {
|
||||
void onDismiss();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user