Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove account when user clears app data #440

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:manageSpaceActivity="com.odysee.app.ClearDataActivity"
android:requestLegacyExternalStorage="true"
android:supportsRtl="true"
android:theme="@style/AppTheme"
Expand Down Expand Up @@ -136,6 +137,8 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.odysee.app.ClearDataActivity" />
<activity
android:name=".ComingSoon"
android:theme="@style/AppTheme.NoActionBar"/>
Expand Down
38 changes: 38 additions & 0 deletions app/src/main/java/com/odysee/app/ClearDataActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.odysee.app;

import androidx.appcompat.app.AppCompatActivity;

import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.ActivityManager;
import android.content.Context;
import android.os.Bundle;
import android.view.View;

import com.odysee.app.utils.Helper;

public class ClearDataActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_clear_data);

Context context = this;

findViewById(R.id.clear_data_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// The "clear data" Android mechanism doesn't remove accounts, so Odysee has to do it
AccountManager am = AccountManager.get(context);
Account odyseeAccount = Helper.getOdyseeAccount(am.getAccounts());

if (odyseeAccount != null) {
am.removeAccountExplicitly(odyseeAccount);
}

((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)).clearApplicationUserData();
}
});
}
}
28 changes: 28 additions & 0 deletions app/src/main/res/layout/activity_clear_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ClearDataActivity">

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
android:text="@string/clear_data_log_out"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<Button
android:id="@+id/clear_data_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="@string/clear_data"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView2" />
</androidx.constraintlayout.widget.ConstraintLayout>
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1039,4 +1039,7 @@

<string name="fa_bell" translatable="false">&#xf0f3;</string>
<string name="fa_bell_slash" translatable="false">&#xf1f6;</string>

<string name="clear_data_log_out">Clearing this app\'s data will also log out of your account</string>
<string name="clear_data">Clear Data</string>
</resources>