worked on repo info, files tabs and files activity

This commit is contained in:
M M Arif 2020-03-04 21:15:57 +05:00
parent d557999a38
commit a8cc4c00b8
5 changed files with 59 additions and 49 deletions

View File

@ -10,10 +10,10 @@ import android.util.Base64;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import com.github.barteksc.pdfviewer.PDFView;
import com.github.barteksc.pdfviewer.util.FitPolicy;
@ -37,23 +37,29 @@ import retrofit2.Callback;
* Author M M Arif
*/
public class FileViewActivity extends AppCompatActivity {
public class FileViewActivity extends BaseActivity {
private View.OnClickListener onClickListener;
private TextView singleFileContents;
private LinearLayout singleFileContentsFrame;
private HighlightJsView singleCodeContents;
private PhotoView imageView;
final Context ctx = this;
private ProgressBar mProgressBar;
private byte[] imageData;
private PDFView pdfView;
private LinearLayout pdfViewFrame;
private byte[] decodedPdf;
@Override
protected void onCreate(Bundle savedInstanceState) {
protected int getLayoutResourceId(){
return R.layout.activity_file_view;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_file_view);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
@ -70,9 +76,10 @@ public class FileViewActivity extends AppCompatActivity {
singleFileContents = findViewById(R.id.singleFileContents);
singleCodeContents = findViewById(R.id.singleCodeContents);
imageView = findViewById(R.id.imageView);
singleFileContents.setVisibility(View.GONE);
mProgressBar = findViewById(R.id.progress_bar);
pdfView = findViewById(R.id.pdfView);
pdfViewFrame = findViewById(R.id.pdfViewFrame);
singleFileContentsFrame = findViewById(R.id.singleFileContentsFrame);
String singleFileName = getIntent().getStringExtra("singleFileName");
@ -126,8 +133,9 @@ public class FileViewActivity extends AppCompatActivity {
if(appUtil.imageExtension(fileExtension)) { // file is image
singleFileContents.setVisibility(View.GONE);
singleFileContentsFrame.setVisibility(View.GONE);
singleCodeContents.setVisibility(View.GONE);
pdfViewFrame.setVisibility(View.GONE);
imageView.setVisibility(View.VISIBLE);
imageData = Base64.decode(response.body().getContent(), Base64.DEFAULT);
@ -138,7 +146,8 @@ public class FileViewActivity extends AppCompatActivity {
else if (appUtil.sourceCodeExtension(fileExtension)) { // file is sourcecode
imageView.setVisibility(View.GONE);
singleFileContents.setVisibility(View.GONE);
singleFileContentsFrame.setVisibility(View.GONE);
pdfViewFrame.setVisibility(View.GONE);
singleCodeContents.setVisibility(View.VISIBLE);
singleCodeContents.setTheme(Theme.GRUVBOX_DARK);
@ -149,9 +158,9 @@ public class FileViewActivity extends AppCompatActivity {
else if (appUtil.pdfExtension(fileExtension)) { // file is pdf
imageView.setVisibility(View.GONE);
singleFileContents.setVisibility(View.GONE);
singleFileContentsFrame.setVisibility(View.GONE);
singleCodeContents.setVisibility(View.GONE);
pdfView.setVisibility(View.VISIBLE);
pdfViewFrame.setVisibility(View.VISIBLE);
decodedPdf = Base64.decode(response.body().getContent(), Base64.DEFAULT);
pdfView.fromBytes(decodedPdf)
@ -169,7 +178,7 @@ public class FileViewActivity extends AppCompatActivity {
.fitEachPage(true)
.pageSnap(false)
.pageFling(true)
.nightMode(true)
.nightMode(false)
.load();
}
@ -177,7 +186,8 @@ public class FileViewActivity extends AppCompatActivity {
imageView.setVisibility(View.GONE);
singleCodeContents.setVisibility(View.GONE);
singleFileContents.setVisibility(View.VISIBLE);
pdfViewFrame.setVisibility(View.GONE);
singleFileContentsFrame.setVisibility(View.VISIBLE);
singleFileContents.setText(appUtil.decodeBase64(response.body().getContent()));

View File

@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/colorPrimary">
android:background="?attr/primaryBackgroundColor">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
@ -15,7 +15,7 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:background="?attr/primaryBackgroundColor"
tools:ignore="UnusedAttribute">
<ImageView
@ -34,7 +34,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/defaultFilename"
android:textColor="@color/white"
android:textColor="?attr/primaryTextColor"
android:ellipsize="none"
android:scrollbars="horizontal"
android:singleLine="true"
@ -46,10 +46,11 @@
</com.google.android.material.appbar.AppBarLayout>
<LinearLayout
android:id="@+id/singleFileContentsFrame"
android:layout_marginTop="50dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:background="?attr/primaryBackgroundColor"
android:orientation="vertical">
<ScrollView
@ -61,7 +62,7 @@
android:id="@+id/singleFileContents"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/colorWhite"
android:textColor="?attr/primaryTextColor"
android:textSize="14sp"
android:padding="15dp"
android:textIsSelectable="true"
@ -72,18 +73,18 @@
</LinearLayout>
<LinearLayout
android:id="@+id/pdfViewFrame"
android:layout_marginTop="55dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:background="?attr/primaryBackgroundColor"
android:orientation="vertical">
<com.github.barteksc.pdfviewer.PDFView
android:id="@+id/pdfView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black"
android:visibility="visible" />
android:background="?attr/primaryBackgroundColor" />
</LinearLayout>

View File

@ -9,8 +9,7 @@
android:fitsSystemWindows="true"
android:orientation="vertical"
android:layout_margin="10dp"
android:theme="@style/AppTheme"
android:background="@color/backgroundColor"
android:background="?attr/primaryBackgroundColor"
tools:context=".activities.MainActivity">
<TextView
@ -41,7 +40,7 @@
android:layout_weight=".80"
android:layout_marginBottom="0dp"
android:text="@string/defaultFilename"
android:textColor="@color/white"
android:textColor="?attr/primaryTextColor"
android:textSize="16sp" />
<ImageView

View File

@ -26,7 +26,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:CustomTextSize="16sp"
app:SelectedTextColor="@color/colorAccent"
app:SelectedTextColor="?attr/primaryTextColor"
app:UnSelectedTextColor="@color/lightGray"
android:text="@string/filesBreadcrumbRoot"/>
@ -34,7 +34,7 @@
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:background="?attr/primaryBackgroundColor"
android:padding="4dp"
android:scrollbars="vertical" />
@ -45,7 +45,7 @@
android:layout_margin="15dp"
android:gravity="center"
android:text="@string/noDataFilesTab"
android:textColor="@color/white"
android:textColor="?attr/primaryTextColor"
android:textSize="20sp"
android:visibility="gone" />

View File

@ -6,7 +6,7 @@
<ScrollView
android:orientation="vertical"
android:background="@color/backgroundColor"
android:background="?attr/primaryBackgroundColor"
android:layout_width="match_parent"
android:layout_height="match_parent">
@ -61,7 +61,7 @@
android:layout_height="match_parent"
android:text="@string/infoTabRepoName1"
android:textSize="16sp"
android:textColor="@color/white"/>
android:textColor="?attr/primaryTextColor"/>
<TextView
android:id="@+id/repoNameInfo"
@ -71,14 +71,14 @@
android:textIsSelectable="true"
android:textSize="14sp"
android:paddingTop="5dp"
android:textColor="@color/colorWhite"/>
android:textColor="?attr/primaryTextColor"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/infoTabRepoOwner1"
android:textSize="16sp"
android:textColor="@color/white"
android:textColor="?attr/primaryTextColor"
android:layout_marginTop="15dp"/>
<TextView
@ -89,14 +89,14 @@
android:textIsSelectable="true"
android:textSize="14sp"
android:paddingTop="5dp"
android:textColor="@color/colorWhite"/>
android:textColor="?attr/primaryTextColor"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/infoTabRepoDesc"
android:textSize="16sp"
android:textColor="@color/white"
android:textColor="?attr/primaryTextColor"
android:layout_marginTop="15dp"/>
<TextView
@ -108,14 +108,14 @@
android:textSize="14sp"
android:paddingTop="5dp"
android:autoLink="web"
android:textColor="@color/colorWhite"/>
android:textColor="?attr/primaryTextColor"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/infoTabRepoWebsite"
android:textSize="16sp"
android:textColor="@color/white"
android:textColor="?attr/primaryTextColor"
android:layout_marginTop="15dp"/>
<TextView
@ -128,14 +128,14 @@
android:paddingTop="5dp"
android:autoLink="web"
android:textColorLink="@color/lightBlue"
android:textColor="@color/colorWhite"/>
android:textColor="?attr/primaryTextColor"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/infoTabRepoSize"
android:textSize="16sp"
android:textColor="@color/white"
android:textColor="?attr/primaryTextColor"
android:layout_marginTop="15dp"/>
<TextView
@ -146,14 +146,14 @@
android:textIsSelectable="true"
android:textSize="14sp"
android:paddingTop="5dp"
android:textColor="@color/colorWhite"/>
android:textColor="?attr/primaryTextColor"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/infoTabRepoDefaultBranch"
android:textSize="16sp"
android:textColor="@color/white"
android:textColor="?attr/primaryTextColor"
android:layout_marginTop="15dp"/>
<TextView
@ -164,14 +164,14 @@
android:textIsSelectable="true"
android:textSize="14sp"
android:paddingTop="5dp"
android:textColor="@color/colorWhite"/>
android:textColor="?attr/primaryTextColor"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/infoTabRepoSshUrl"
android:textSize="16sp"
android:textColor="@color/white"
android:textColor="?attr/primaryTextColor"
android:layout_marginTop="15dp"/>
<TextView
@ -184,14 +184,14 @@
android:paddingTop="5dp"
android:autoLink="web"
android:textColorLink="@color/lightBlue"
android:textColor="@color/colorWhite"/>
android:textColor="?attr/primaryTextColor"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/infoTabRepoCloneUrl"
android:textSize="16sp"
android:textColor="@color/white"
android:textColor="?attr/primaryTextColor"
android:layout_marginTop="15dp"/>
<TextView
@ -204,14 +204,14 @@
android:paddingTop="5dp"
android:autoLink="web"
android:textColorLink="@color/lightBlue"
android:textColor="@color/colorWhite"/>
android:textColor="?attr/primaryTextColor"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/infoTabRepoRepoUrl"
android:textSize="16sp"
android:textColor="@color/white"
android:textColor="?attr/primaryTextColor"
android:layout_marginTop="15dp"/>
<TextView
@ -224,14 +224,14 @@
android:paddingTop="5dp"
android:autoLink="web"
android:textColorLink="@color/lightBlue"
android:textColor="@color/colorWhite"/>
android:textColor="?attr/primaryTextColor"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/infoTabRepoForksCount"
android:textSize="16sp"
android:textColor="@color/white"
android:textColor="?attr/primaryTextColor"
android:layout_marginTop="15dp"/>
<TextView
@ -242,14 +242,14 @@
android:textIsSelectable="true"
android:textSize="14sp"
android:paddingTop="5dp"
android:textColor="@color/colorWhite"/>
android:textColor="?attr/primaryTextColor"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/infoTabRepoCreatedAt"
android:textSize="16sp"
android:textColor="@color/white"
android:textColor="?attr/primaryTextColor"
android:layout_marginTop="15dp"/>
<TextView
@ -259,7 +259,7 @@
android:text="@string/infoTabRepoDummyTime"
android:textSize="14sp"
android:paddingTop="5dp"
android:textColor="@color/colorWhite"/>
android:textColor="?attr/primaryTextColor"/>
</LinearLayout>
@ -310,7 +310,7 @@
android:layout_height="wrap_content"
android:textIsSelectable="true"
android:textSize="16sp"
android:textColor="@color/colorWhite"/>
android:textColor="?attr/primaryTextColor"/>
</LinearLayout>