From a00d76d0e2b99d99893c6cab763e1d3144f9dabc Mon Sep 17 00:00:00 2001 From: M M Arif Date: Thu, 26 Dec 2019 00:14:33 +0500 Subject: [PATCH] backport url slashes fix --- app/build.gradle | 4 ++-- .../java/org/mian/gitnex/activities/FileViewActivity.java | 4 +++- .../java/org/mian/gitnex/fragments/FilesFragment.java | 8 ++++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 068516b9..122d0361 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -23,12 +23,12 @@ android { } dependencies { - def lifecycle_version = "2.2.0-rc02" + def lifecycle_version = "2.2.0-rc03" final def markwon_version = "4.1.1" implementation fileTree(include: ['*.jar'], dir: 'libs') implementation "androidx.appcompat:appcompat:1.1.0" - implementation "com.google.android.material:material:1.2.0-alpha02" + implementation "com.google.android.material:material:1.2.0-alpha03" implementation "androidx.constraintlayout:constraintlayout:1.1.3" implementation "androidx.legacy:legacy-support-v4:1.0.0" testImplementation "junit:junit:4.12" diff --git a/app/src/main/java/org/mian/gitnex/activities/FileViewActivity.java b/app/src/main/java/org/mian/gitnex/activities/FileViewActivity.java index a602e4c0..760fe6c6 100644 --- a/app/src/main/java/org/mian/gitnex/activities/FileViewActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/FileViewActivity.java @@ -73,7 +73,6 @@ public class FileViewActivity extends AppCompatActivity { TextView toolbar_title = findViewById(R.id.toolbar_title); toolbar_title.setMovementMethod(new ScrollingMovementMethod()); - toolbar_title.setText(singleFileName); initCloseListener(); closeActivity.setOnClickListener(onClickListener); @@ -82,6 +81,7 @@ public class FileViewActivity extends AppCompatActivity { singleFileName = URLDecoder.decode(singleFileName, "UTF-8"); singleFileName = singleFileName.replaceAll("//", "/"); + singleFileName = singleFileName.startsWith("/") ? singleFileName.substring(1) : singleFileName; } catch (UnsupportedEncodingException e) { @@ -91,6 +91,8 @@ public class FileViewActivity extends AppCompatActivity { } + toolbar_title.setText(singleFileName); + getSingleFileContents(instanceUrl, instanceToken, repoOwner, repoName, singleFileName); } diff --git a/app/src/main/java/org/mian/gitnex/fragments/FilesFragment.java b/app/src/main/java/org/mian/gitnex/fragments/FilesFragment.java index 80b64581..4387c28a 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/FilesFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/FilesFragment.java @@ -140,6 +140,10 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter fileStructure.setText(breadcrumbBuilder); + String dirName_ = fileStructure.getText().toString(); + dirName_ = dirName_.startsWith("/") ? dirName_.substring(1) : dirName_; + final String finalDirName_ = dirName_; + mBreadcrumbsView.addItem(createItem(dirName)); mBreadcrumbsView.setCallback(new DefaultBreadcrumbsCallback() { @Override @@ -154,7 +158,7 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter String filterDir = fileStructure.getText().toString(); String result = filterDir.substring(0, filterDir.indexOf(item.getSelectedItem())); fileStructure.setText(result + item.getSelectedItem()); - fetchDataAsyncSub(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, fileStructure.getText().toString()); + fetchDataAsyncSub(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, finalDirName_); } @@ -164,7 +168,7 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter } }); - fetchDataAsyncSub(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, fileStructure.getText().toString()); + fetchDataAsyncSub(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, finalDirName_); }