Merge branch '175-fileview-support-images' of gitnex/GitNex into master
This commit is contained in:
commit
d184bdca12
|
@ -1,13 +1,13 @@
|
||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 28
|
compileSdkVersion 29
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "org.mian.gitnex"
|
applicationId "org.mian.gitnex"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 28
|
targetSdkVersion 29
|
||||||
versionCode 70
|
versionCode 80
|
||||||
versionName "2.2.0"
|
versionName "2.3.0-dev"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
@ -23,30 +23,29 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
def lifecycle_version = "2.2.0-beta01"
|
def lifecycle_version = "2.2.0-rc01"
|
||||||
final def markwon_version = "4.1.1"
|
final def markwon_version = "4.1.1"
|
||||||
|
|
||||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
implementation "androidx.appcompat:appcompat:1.1.0"
|
||||||
implementation 'com.google.android.material:material:1.1.0-beta01'
|
implementation "com.google.android.material:material:1.2.0-alpha01"
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
|
||||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
implementation "androidx.legacy:legacy-support-v4:1.0.0"
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation "junit:junit:4.12"
|
||||||
androidTestImplementation 'androidx.test:runner:1.2.0'
|
androidTestImplementation "androidx.test:runner:1.2.0"
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
androidTestImplementation "androidx.test.espresso:espresso-core:3.2.0"
|
||||||
implementation 'com.github.vihtarb:tooltip:0.2.0'
|
implementation "com.github.vihtarb:tooltip:0.2.0"
|
||||||
implementation 'com.squareup.okhttp3:okhttp:3.12.1'
|
implementation "com.squareup.okhttp3:okhttp:3.12.1"
|
||||||
implementation 'com.google.code.gson:gson:2.8.5'
|
implementation "com.google.code.gson:gson:2.8.5"
|
||||||
implementation 'com.squareup.picasso:picasso:2.71828'
|
implementation "com.squareup.picasso:picasso:2.71828"
|
||||||
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
|
implementation "com.amulyakhare:com.amulyakhare.textdrawable:1.0.1"
|
||||||
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
|
implementation "com.squareup.retrofit2:retrofit:2.5.0"
|
||||||
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
|
implementation "com.squareup.retrofit2:converter-gson:2.5.0"
|
||||||
implementation 'com.squareup.retrofit2:converter-scalars:2.5.0'
|
implementation "com.squareup.retrofit2:converter-scalars:2.5.0"
|
||||||
implementation 'com.squareup.okhttp3:logging-interceptor:3.12.1'
|
implementation "com.squareup.okhttp3:logging-interceptor:3.12.1"
|
||||||
implementation 'org.ocpsoft.prettytime:prettytime:4.0.1.Final'
|
implementation "org.ocpsoft.prettytime:prettytime:4.0.1.Final"
|
||||||
implementation "com.vdurmont:emoji-java:4.0.0"
|
implementation "com.vdurmont:emoji-java:4.0.0"
|
||||||
implementation "com.pes.materialcolorpicker:library:1.2.5"
|
implementation "com.pes.materialcolorpicker:library:1.2.5"
|
||||||
|
|
||||||
implementation "io.noties.markwon:core:$markwon_version"
|
implementation "io.noties.markwon:core:$markwon_version"
|
||||||
implementation "io.noties.markwon:ext-latex:$markwon_version"
|
implementation "io.noties.markwon:ext-latex:$markwon_version"
|
||||||
implementation "io.noties.markwon:ext-strikethrough:$markwon_version"
|
implementation "io.noties.markwon:ext-strikethrough:$markwon_version"
|
||||||
|
@ -61,13 +60,12 @@ dependencies {
|
||||||
implementation "io.noties.markwon:simple-ext:$markwon_version"
|
implementation "io.noties.markwon:simple-ext:$markwon_version"
|
||||||
implementation "io.noties.markwon:syntax-highlight:$markwon_version"
|
implementation "io.noties.markwon:syntax-highlight:$markwon_version"
|
||||||
implementation "com.caverock:androidsvg:1.4"
|
implementation "com.caverock:androidsvg:1.4"
|
||||||
implementation "pl.droidsonroids.gif:android-gif-drawable:1.2.14"
|
implementation "pl.droidsonroids.gif:android-gif-drawable:1.2.19"
|
||||||
|
|
||||||
implementation "com.hendraanggrian.appcompat:socialview:0.2"
|
implementation "com.hendraanggrian.appcompat:socialview:0.2"
|
||||||
implementation "com.hendraanggrian.appcompat:socialview-commons:0.2"
|
implementation "com.hendraanggrian.appcompat:socialview-commons:0.2"
|
||||||
|
|
||||||
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
|
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
|
||||||
implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
|
implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
|
||||||
|
|
||||||
implementation "com.github.HamidrezaAmz:BreadcrumbsView:0.2.9"
|
implementation "com.github.HamidrezaAmz:BreadcrumbsView:0.2.9"
|
||||||
|
implementation "commons-io:commons-io:2.6"
|
||||||
|
implementation "com.github.chrisbanes:PhotoView:2.3.0"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.method.ScrollingMovementMethod;
|
import android.text.method.ScrollingMovementMethod;
|
||||||
|
import android.util.Base64;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
@ -11,6 +15,8 @@ import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
import com.github.chrisbanes.photoview.PhotoView;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.helpers.AlertDialogs;
|
import org.mian.gitnex.helpers.AlertDialogs;
|
||||||
|
@ -29,8 +35,10 @@ public class FileViewActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
private TextView singleFileContents;
|
private TextView singleFileContents;
|
||||||
|
private PhotoView imageView;
|
||||||
final Context ctx = this;
|
final Context ctx = this;
|
||||||
private ProgressBar mProgressBar;
|
private ProgressBar mProgressBar;
|
||||||
|
private byte[] imageData;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -53,6 +61,7 @@ public class FileViewActivity extends AppCompatActivity {
|
||||||
|
|
||||||
ImageView closeActivity = findViewById(R.id.close);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
singleFileContents = findViewById(R.id.singleFileContents);
|
singleFileContents = findViewById(R.id.singleFileContents);
|
||||||
|
imageView = findViewById(R.id.imageView);
|
||||||
singleFileContents.setVisibility(View.GONE);
|
singleFileContents.setVisibility(View.GONE);
|
||||||
mProgressBar = findViewById(R.id.progress_bar);
|
mProgressBar = findViewById(R.id.progress_bar);
|
||||||
|
|
||||||
|
@ -92,9 +101,27 @@ public class FileViewActivity extends AppCompatActivity {
|
||||||
assert response.body() != null;
|
assert response.body() != null;
|
||||||
|
|
||||||
if(!response.body().getContent().equals("")) {
|
if(!response.body().getContent().equals("")) {
|
||||||
singleFileContents.setVisibility(View.VISIBLE);
|
|
||||||
|
String fileExtension = FilenameUtils.getExtension(filename);
|
||||||
mProgressBar.setVisibility(View.GONE);
|
mProgressBar.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
if(fileExtension.equals("png") || fileExtension.equals("jpg") || fileExtension.equals("jpeg") || fileExtension.equals("gif")) {
|
||||||
|
|
||||||
|
singleFileContents.setVisibility(View.GONE);
|
||||||
|
imageView.setVisibility(View.VISIBLE);
|
||||||
|
imageData = Base64.decode(response.body().getContent(), Base64.DEFAULT);
|
||||||
|
Drawable imageDrawable = new BitmapDrawable(getResources(), BitmapFactory.decodeByteArray(imageData, 0, imageData.length));
|
||||||
|
imageView.setImageDrawable(imageDrawable);
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
imageView.setVisibility(View.GONE);
|
||||||
|
singleFileContents.setVisibility(View.VISIBLE);
|
||||||
singleFileContents.setText(appUtil.decodeBase64(response.body().getContent()));
|
singleFileContents.setText(appUtil.decodeBase64(response.body().getContent()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
singleFileContents.setText("");
|
singleFileContents.setText("");
|
||||||
|
|
|
@ -49,7 +49,8 @@
|
||||||
android:layout_marginTop="50dp"
|
android:layout_marginTop="50dp"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@color/toastBackground">
|
android:background="@color/black"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -69,6 +70,13 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<com.github.chrisbanes.photoview.PhotoView
|
||||||
|
android:id="@+id/imageView"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progress_bar"
|
android:id="@+id/progress_bar"
|
||||||
style="@style/Base.Widget.AppCompat.ProgressBar"
|
style="@style/Base.Widget.AppCompat.ProgressBar"
|
||||||
|
|
Loading…
Reference in New Issue