Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Commit

Permalink
Kill Riot-Android (for F-Droid users) (Fixes #3507)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmarty committed Aug 25, 2020
1 parent 9a68b05 commit dc034c7
Show file tree
Hide file tree
Showing 13 changed files with 135 additions and 2 deletions.
6 changes: 5 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changes in Riot 0.9.13 (2020-XX-XX)
Changes in Riot 0.9.13 (2020-08-25)
===================================================

Riot-Android is now deprecated, and not maintained by the core team anymore.
The version 0.9.13 contains code to inform F-Droid users that the application is deprecated and they have to install Element Android instead (#3507).
This branch will never be merged on develop.

MatrixSdk 🚀:
- Upgrade MatrixSdk to version 0.X.Y.
- Changelog: https://github.com/matrix-org/matrix-android-sdk/releases/tag/v0.X.Y
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ buildscript {
// global properties used in sub modules
ext {
versionCodeProp = 90913
versionNameProp = "0.9.13-dev"
versionNameProp = "0.9.13"
versionBuild = System.getenv("BUILD_NUMBER") as Integer ?: 0
buildNumberProp = "${versionBuild}"
}
Expand Down
3 changes: 3 additions & 0 deletions vector/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
<!-- disable the battery optimisation on some devices to let the background sync works -->
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />

<!-- To be able to delete the app -->
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />

<!-- videocall feature -->
<!-- android.permission.CAMERA defines android.hardware.camera -->
<uses-feature
Expand Down
4 changes: 4 additions & 0 deletions vector/src/main/java/im/vector/activity/LoginActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@
import im.vector.util.PhoneNumberUtils;
import im.vector.util.ViewUtilKt;

import static im.vector.disclaimer.DisclaimerDialogKt.showDisclaimerDialog;

/**
* Displays the login screen.
*/
Expand Down Expand Up @@ -1072,6 +1074,8 @@ protected void onResume() {
}

refreshDisplay(true);

showDisclaimerDialog(this, false);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@
import im.vector.view.UnreadCounterBadgeView;
import im.vector.view.VectorPendingCallView;

import static im.vector.disclaimer.DisclaimerDialogKt.showDisclaimerDialog;

/**
* Displays the main screen of the app, with rooms the user has joined and the ability to create
* new rooms.
Expand Down Expand Up @@ -570,6 +572,8 @@ private void showFloatingActionMenuIfRequired() {
}
}

private Boolean disclaimerShown = false;

@Override
protected void onResume() {
super.onResume();
Expand Down Expand Up @@ -635,6 +639,11 @@ public void onClick(DialogInterface dialog, int which) {
} catch (Exception e) {
Log.e(LOG_TAG, "## onResume() : appCrashedAlert failed " + e.getMessage(), e);
}
} else {
if (!disclaimerShown) {
disclaimerShown = true;
showDisclaimerDialog(this, true);
}
}

if (null != mMemberIdToOpen) {
Expand Down
64 changes: 64 additions & 0 deletions vector/src/main/java/im/vector/disclaimer/DisclaimerDialog.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright 2019 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package im.vector.disclaimer

import android.app.Activity
import android.content.ActivityNotFoundException
import android.content.Intent
import android.net.Uri
import android.os.Build
import androidx.appcompat.app.AlertDialog
import im.vector.BuildConfig
import im.vector.R
import im.vector.util.openPlayStore
import org.jetbrains.anko.toast

fun showDisclaimerDialog(activity: Activity, allowAppAccess: Boolean) {
// Element is only available on Android 5.0
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
return
}

val dialogLayout = activity.layoutInflater.inflate(R.layout.dialog_disclaimer_content, null)

AlertDialog.Builder(activity)
.setView(dialogLayout)
.setCancelable(allowAppAccess)
.apply {
if (allowAppAccess) {
setNegativeButton(R.string.element_disclaimer_negative_button, null)
} else {
setNegativeButton(R.string.action_close) { _, _ -> /* DO NOT COMMIT activity.finish() */ }
setNeutralButton(R.string.element_disclaimer_uninstall_button) { _, _ -> uninstall(activity) }
}
}
.setPositiveButton(R.string.element_disclaimer_positive_button) { _, _ ->
openPlayStore(activity, "im.vector.app")
}
.show()
}

private fun uninstall(activity: Activity) {
@Suppress("DEPRECATION")
val intent = Intent(Intent.ACTION_UNINSTALL_PACKAGE)
intent.data = Uri.parse("package:" + BuildConfig.APPLICATION_ID)
try {
activity.startActivity(intent)
} catch (anfe: ActivityNotFoundException) {
activity.toast(R.string.error_no_external_application_found)
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions vector/src/main/res/layout/dialog_disclaimer_content.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
android:id="@+id/disclaimerIcons"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="32dp"
android:src="@drawable/riot_to_element"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/disclaimerTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/element_disclaimer_title"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/disclaimerIcons" />

<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="24dp"
android:gravity="center"
android:paddingBottom="32dp"
android:text="@string/element_disclaimer_content"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/disclaimerTextView" />

</androidx.constraintlayout.widget.ConstraintLayout>
6 changes: 6 additions & 0 deletions vector/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1568,4 +1568,10 @@ Why choose Riot.im?
<string name="settings_discovery_disconnect_with_bound_pid">You are currently sharing email addresses or phone numbers on the identity server %1$s. You will need to reconnect to %2$s to stop sharing them.</string>
<string name="settings_agree_to_terms">Agree to the identity server (%s) Terms of Service to allow yourself to be discoverable by email address or phone number.</string>

<string name="element_disclaimer_title">Riot is now Element!</string>
<string name="element_disclaimer_content">We’re excited to announce we’ve changed name!\n\nYou have to install the new Element Android application and sign in again.</string>
<string name="element_disclaimer_negative_button">Later</string>
<string name="element_disclaimer_positive_button">Get Element</string>
<string name="element_disclaimer_uninstall_button">Uninstall</string>

</resources>

0 comments on commit dc034c7

Please sign in to comment.