Use new nextcloud-commons library for SSO Glide integration

https://github.com/stefan-niedermann/nextcloud-commons

Signed-off-by: stefan-niedermann <info@niedermann.it>
This commit is contained in:
stefan-niedermann 2020-02-12 18:02:44 +01:00
parent 58eaaa84bc
commit e87ddac3a0
11 changed files with 18 additions and 125 deletions

View file

@ -34,7 +34,7 @@ android {
dependencies {
implementation "com.github.nextcloud:Android-SingleSignOn:0.5.0-rc2"
implementation 'com.github.stefan-niedermann:nextcloud-commons:6250e5fe73'
implementation 'com.github.stefan-niedermann:nextcloud-commons:0.0.1'
implementation 'com.yydcdut:markdown-processor:0.1.3'
implementation 'com.yydcdut:rxmarkdown-wrapper:0.1.3'

View file

@ -14,11 +14,11 @@ import com.google.android.material.tabs.TabLayout;
import butterknife.BindView;
import butterknife.ButterKnife;
import it.niedermann.nextcloud.exception.ExceptionHandler;
import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.android.fragment.about.AboutFragmentContributingTab;
import it.niedermann.owncloud.notes.android.fragment.about.AboutFragmentCreditsTab;
import it.niedermann.owncloud.notes.android.fragment.about.AboutFragmentLicenseTab;
import it.niedermann.owncloud.notes.util.ExceptionHandler;
public class AboutActivity extends AppCompatActivity {
@ -32,7 +32,7 @@ public class AboutActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Thread.currentThread().setUncaughtExceptionHandler(new ExceptionHandler(this));
Thread.currentThread().setUncaughtExceptionHandler(new ExceptionHandler(this, ExceptionActivity.class));
setContentView(R.layout.activity_about);
ButterKnife.bind(this);

View file

@ -21,6 +21,7 @@ import java.util.Objects;
import butterknife.BindView;
import butterknife.ButterKnife;
import it.niedermann.nextcloud.exception.ExceptionHandler;
import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.android.fragment.BaseNoteFragment;
import it.niedermann.owncloud.notes.android.fragment.NoteEditFragment;
@ -30,7 +31,6 @@ import it.niedermann.owncloud.notes.model.Category;
import it.niedermann.owncloud.notes.model.CloudNote;
import it.niedermann.owncloud.notes.model.DBNote;
import it.niedermann.owncloud.notes.model.LocalAccount;
import it.niedermann.owncloud.notes.util.ExceptionHandler;
import it.niedermann.owncloud.notes.util.NoteUtil;
import static it.niedermann.owncloud.notes.android.fragment.AccountChooserAdapter.AccountChooserListener;
@ -55,7 +55,7 @@ public class EditNoteActivity extends AppCompatActivity implements BaseNoteFragm
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Thread.currentThread().setUncaughtExceptionHandler(new ExceptionHandler(this));
Thread.currentThread().setUncaughtExceptionHandler(new ExceptionHandler(this, ExceptionActivity.class));
setContentView(R.layout.activity_edit);

View file

@ -14,8 +14,10 @@ import androidx.appcompat.widget.Toolbar;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import it.niedermann.nextcloud.exception.ExceptionUtil;
import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.util.ExceptionUtil;
import static it.niedermann.nextcloud.exception.ExceptionHandler.KEY_THROWABLE;
public class ExceptionActivity extends AppCompatActivity {
@ -28,8 +30,6 @@ public class ExceptionActivity extends AppCompatActivity {
@BindView(R.id.stacktrace)
TextView stacktrace;
public static final String KEY_THROWABLE = "T";
@SuppressLint("SetTextI18n") // only used for logging
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
@ -38,7 +38,6 @@ public class ExceptionActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setSupportActionBar(toolbar);
throwable = ((Throwable) getIntent().getSerializableExtra(KEY_THROWABLE));
throwable.printStackTrace();
toolbar.setTitle(getString(R.string.simple_error));
this.message.setText(throwable.getMessage());
this.stacktrace.setText(ExceptionUtil.getDebugInfos(this, throwable));

View file

@ -51,6 +51,7 @@ import java.util.Map;
import butterknife.BindView;
import butterknife.ButterKnife;
import it.niedermann.nextcloud.exception.ExceptionHandler;
import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.android.MultiSelectedActionModeCallback;
import it.niedermann.owncloud.notes.android.NotesListViewItemTouchHelper;
@ -68,7 +69,6 @@ import it.niedermann.owncloud.notes.persistence.LoadNotesListTask;
import it.niedermann.owncloud.notes.persistence.LoadNotesListTask.NotesLoadedListener;
import it.niedermann.owncloud.notes.persistence.NoteSQLiteOpenHelper;
import it.niedermann.owncloud.notes.persistence.NoteServerSyncHelper;
import it.niedermann.owncloud.notes.util.ExceptionHandler;
import it.niedermann.owncloud.notes.util.NoteUtil;
import static it.niedermann.owncloud.notes.util.SSOUtil.askForNewAccount;
@ -155,7 +155,7 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Thread.currentThread().setUncaughtExceptionHandler(new ExceptionHandler(this));
Thread.currentThread().setUncaughtExceptionHandler(new ExceptionHandler(this, ExceptionActivity.class));
setContentView(R.layout.drawer_layout);
ButterKnife.bind(this);

View file

@ -8,9 +8,9 @@ import androidx.appcompat.widget.Toolbar;
import butterknife.BindView;
import butterknife.ButterKnife;
import it.niedermann.nextcloud.exception.ExceptionHandler;
import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.android.fragment.PreferencesFragment;
import it.niedermann.owncloud.notes.util.ExceptionHandler;
/**
* Allows to change application settings.
@ -24,7 +24,7 @@ public class PreferencesActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Thread.currentThread().setUncaughtExceptionHandler(new ExceptionHandler(this));
Thread.currentThread().setUncaughtExceptionHandler(new ExceptionHandler(this, ExceptionActivity.class));
setContentView(R.layout.activity_preferences);
ButterKnife.bind(this);
setSupportActionBar(toolbar);

View file

@ -11,11 +11,11 @@ import android.view.View;
import butterknife.BindView;
import butterknife.ButterKnife;
import it.niedermann.nextcloud.exception.ExceptionHandler;
import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.android.appwidget.SingleNoteWidget;
import it.niedermann.owncloud.notes.model.DBNote;
import it.niedermann.owncloud.notes.model.Item;
import it.niedermann.owncloud.notes.util.ExceptionHandler;
import it.niedermann.owncloud.notes.util.Notes;
public class SelectSingleNoteActivity extends NotesListViewActivity {
@ -26,7 +26,7 @@ public class SelectSingleNoteActivity extends NotesListViewActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Thread.currentThread().setUncaughtExceptionHandler(new ExceptionHandler(this));
Thread.currentThread().setUncaughtExceptionHandler(new ExceptionHandler(this, ExceptionActivity.class));
setResult(Activity.RESULT_CANCELED);
ButterKnife.bind(this);

View file

@ -5,7 +5,8 @@ import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import it.niedermann.owncloud.notes.util.ExceptionHandler;
import it.niedermann.nextcloud.exception.ExceptionHandler;
/**
* Created by stefan on 18.04.17.
@ -15,7 +16,7 @@ public class SplashscreenActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Thread.currentThread().setUncaughtExceptionHandler(new ExceptionHandler(this));
Thread.currentThread().setUncaughtExceptionHandler(new ExceptionHandler(this, ExceptionActivity.class));
Intent intent = new Intent(this, NotesListViewActivity.class);
startActivity(intent);

View file

@ -42,6 +42,7 @@ import java.util.Map;
import java.util.Objects;
import java.util.Set;
import it.niedermann.nextcloud.exception.ExceptionUtil;
import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.model.CloudNote;
import it.niedermann.owncloud.notes.model.DBNote;
@ -50,7 +51,6 @@ import it.niedermann.owncloud.notes.model.ISyncCallback;
import it.niedermann.owncloud.notes.model.LocalAccount;
import it.niedermann.owncloud.notes.model.LoginStatus;
import it.niedermann.owncloud.notes.model.SyncResultStatus;
import it.niedermann.owncloud.notes.util.ExceptionUtil;
import it.niedermann.owncloud.notes.util.SSOUtil;
import it.niedermann.owncloud.notes.util.ServerResponse;

View file

@ -1,35 +0,0 @@
package it.niedermann.owncloud.notes.util;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import java.io.Serializable;
import it.niedermann.owncloud.notes.android.activity.ExceptionActivity;
import static it.niedermann.owncloud.notes.android.activity.ExceptionActivity.KEY_THROWABLE;
public class ExceptionHandler implements Thread.UncaughtExceptionHandler {
private Activity context;
public ExceptionHandler(Activity context) {
super();
this.context = context;
}
@Override
public void uncaughtException(Thread t, Throwable e) {
e.printStackTrace();
Intent intent = new Intent(context.getApplicationContext(), ExceptionActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
Bundle extras = new Bundle();
intent.putExtra(KEY_THROWABLE, (Serializable) e);
extras.putSerializable(KEY_THROWABLE, e);
intent.putExtras(extras);
context.getApplicationContext().startActivity(intent);
context.finish();
Runtime.getRuntime().exit(0);
}
}

View file

@ -1,72 +0,0 @@
package it.niedermann.owncloud.notes.util;
import android.app.Activity;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import com.nextcloud.android.sso.helper.VersionCheckHelper;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
public class ExceptionUtil {
private ExceptionUtil() {
}
public static String getDebugInfos(Activity activity, Throwable throwable) {
List<Throwable> throwables = new ArrayList<>();
throwables.add(throwable);
return getDebugInfos(activity, throwables);
}
public static String getDebugInfos(Activity activity, List<Throwable> throwables) {
StringBuilder debugInfos = new StringBuilder(""
+ getAppVersions(activity)
+ "\n\n---\n"
+ getDeviceInfos()
+ "\n\n---"
+ "\n\n");
for (Throwable throwable : throwables) {
debugInfos.append(getStacktraceOf(throwable));
}
return debugInfos.toString();
}
private static String getAppVersions(Activity activity) {
String versions = "";
try {
PackageInfo pInfo = activity.getApplicationContext().getPackageManager().getPackageInfo(activity.getApplicationContext().getPackageName(), 0);
versions += "App Version: " + pInfo.versionName;
versions += "\nApp Version Code: " + pInfo.versionCode;
} catch (PackageManager.NameNotFoundException e) {
versions += "\nApp Version: " + e.getMessage();
e.printStackTrace();
}
try {
versions += "\nFiles App Version Code: " + VersionCheckHelper.getNextcloudFilesVersionCode(activity);
} catch (PackageManager.NameNotFoundException e) {
versions += "\nFiles App Version Code: " + e.getMessage();
e.printStackTrace();
}
return versions;
}
private static String getDeviceInfos() {
return ""
+ "\nOS Version: " + System.getProperty("os.version") + "(" + android.os.Build.VERSION.INCREMENTAL + ")"
+ "\nOS API Level: " + android.os.Build.VERSION.SDK_INT
+ "\nDevice: " + android.os.Build.DEVICE
+ "\nModel (and Product): " + android.os.Build.MODEL + " (" + android.os.Build.PRODUCT + ")";
}
private static String getStacktraceOf(Throwable e) {
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
return sw.toString();
}
}