From e7e9ba9d7fbbfe9945e7a1f4622174bc95792c00 Mon Sep 17 00:00:00 2001 From: Apostolof Date: Fri, 20 Jan 2017 22:06:11 +0200 Subject: [PATCH] Fixes for file downloading and login screen. --- app/src/main/AndroidManifest.xml | 6 ++- .../mthmmy/activities/topic/TopicAdapter.java | 40 +++++++++++----- app/src/main/res/layout/activity_login.xml | 48 ++++++++++--------- app/src/main/res/values/strings.xml | 1 - app/src/main/res/xml/provider_paths.xml | 1 - 5 files changed, 57 insertions(+), 39 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7b1efb2d..20248cb4 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -31,9 +31,11 @@ + android:screenOrientation="portrait" + android:theme="@style/AppTheme.NoActionBar" + android:windowSoftInputMode="adjustPan"> { } @Override - protected String doInBackground(ThmmyFile... files) { + protected String doInBackground(ThmmyFile... file) { try { - File tempFile = files[0].download(context); + File tempFile = file[0].download(context); if (tempFile != null) { - String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension( - files[0].getExtension()); + if (file[0].isInternal()) { + String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension( + file[0].getExtension()); - Intent intent = new Intent(); - intent.setAction(android.content.Intent.ACTION_VIEW); - //intent.setDataAndType(Uri.fromFile(tempFile), mime); + Intent intent = new Intent(); + intent.setAction(android.content.Intent.ACTION_VIEW); + //intent.setDataAndType(Uri.fromFile(tempFile), mime); - intent.setDataAndType(FileProvider.getUriForFile(context, context. - getApplicationContext() - .getPackageName() + ".provider", tempFile), mime); + intent.setDataAndType(FileProvider.getUriForFile(context, context. + getApplicationContext() + .getPackageName() + ".provider", tempFile), mime); - intent.setFlags(FLAG_ACTIVITY_NEW_TASK); - context.startActivity(intent); + intent.setFlags(FLAG_ACTIVITY_NEW_TASK); + context.startActivity(intent); + } else { + String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension( + file[0].getExtension()); + + Intent intent = new Intent(); + intent.setAction(android.content.Intent.ACTION_VIEW); + intent.setDataAndType(Uri.fromFile(tempFile), mime); + + /*intent.setDataAndType(FileProvider.getUriForFile(context, context. + getApplicationContext() + .getPackageName() + ".provider", tempFile), mime);*/ + + intent.setFlags(FLAG_ACTIVITY_NEW_TASK); + context.startActivity(intent); + } } } catch (IOException e) { Report.e(TAG, "Error while trying to download a file", e); diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index b79c2503..52bdc281 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -1,7 +1,6 @@ + android:layout_height="match_parent" + android:fillViewport="true" + android:isScrollContainer="false"> + android:layout_height="0dp" + android:layout_weight="0.4"/> + android:layout_height="0dp" + android:layout_weight="0.45"/> + android:layout_height="wrap_content"> + + + + - + android:layout_height="0dp" + android:layout_weight="0.2"/> + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index dccbf7e3..86d8cf67 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -12,7 +12,6 @@ Username Password LOGIN - - OR - Don\'t have an account? Continue as guest! diff --git a/app/src/main/res/xml/provider_paths.xml b/app/src/main/res/xml/provider_paths.xml index d056e2a0..a0b81b43 100644 --- a/app/src/main/res/xml/provider_paths.xml +++ b/app/src/main/res/xml/provider_paths.xml @@ -4,7 +4,6 @@ name="my_downloads" path="Downloads/"/> -