Skip to content

Commit

Permalink
Merge pull request #8 from CubanJaco/master
Browse files Browse the repository at this point in the history
[FIX] NullPointerException al intentar descargar
  • Loading branch information
adrian011494 authored Jul 13, 2021
2 parents a835287 + d34764f commit 0e8de66
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 138 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;

/**
* Instrumented test, which will execute on an Android device.
Expand Down
3 changes: 1 addition & 2 deletions apklisupdate/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cu.uci.apklisupdate"/>
<manifest package="cu.uci.apklisupdate" />
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package cu.uci.apklisupdate

import cu.uci.apklisupdate.model.ApiResponce
import cu.uci.apklisupdate.model.AppUpdateInfo
import io.reactivex.Single
import retrofit2.http.GET
import retrofit2.http.Path
import retrofit2.http.Query

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cu.uci.apklisupdate

import cu.uci.apklisupdate.model.AppUpdateInfo
import java.lang.Exception

interface UpdateCallback {
fun onNewUpdate(appUpdateInfo: AppUpdateInfo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cu.uci.apklisupdate.model
import com.google.gson.annotations.SerializedName

data class LastRelease(
@SerializedName("apk_file") var apk_file: String,
@SerializedName("apk_file") var apk_file: String?,
@SerializedName("changelog") var changelog: String,
@SerializedName("human_readable_size") var human_readable_size: String,
@SerializedName("icon") var icon: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.util.Log
import android.view.View
import androidx.annotation.ColorInt
import com.squareup.picasso.Picasso
import cu.uci.apklisupdate.R
Expand All @@ -22,6 +22,9 @@ class ApklisUpdateDialog(
super.onCreate(savedInstanceState)
setContentView(R.layout.apklis_dialog_update)

if (updateInfo.last_release.apk_file == null)
download.visibility = View.GONE

changelog.setHtml("${context.getString(R.string.changelog)}\n${updateInfo.last_release.changelog}")
version.text = updateInfo.last_release.version_name
title.text = updateInfo.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable
import android.net.Uri
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand Down Expand Up @@ -38,6 +37,9 @@ class ApklisUpdateFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

if (updateInfo.last_release.apk_file == null)
download.visibility = View.GONE

changelog.setHtml("${context?.getString(R.string.changelog)}\n${updateInfo.last_release.changelog}")
version.text = updateInfo.last_release.version_name
title.text = updateInfo.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cu.uci.apklisupdate.view;
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand Down Expand Up @@ -35,6 +34,9 @@ class UpdateFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

if (updateInfo.last_release.apk_file == null)
download.visibility = View.GONE

changelog.setHtml("${context?.getString(R.string.changelog)}\n${updateInfo.last_release.changelog}")
version.text = updateInfo.last_release.changelog

Expand All @@ -59,7 +61,11 @@ class UpdateFragment : Fragment() {

companion object {

fun newInstance(updateInfo: AppUpdateInfo, @DrawableRes background: Int = android.R.color.white, @ColorRes actionsColor: Int = android.R.color.black): UpdateFragment {
fun newInstance(
updateInfo: AppUpdateInfo,
@DrawableRes background: Int = android.R.color.white,
@ColorRes actionsColor: Int = android.R.color.black
): UpdateFragment {
return UpdateFragment().apply {
this.updateInfo = updateInfo
this.background = background
Expand Down
100 changes: 51 additions & 49 deletions apklisupdate/src/main/res/layout/apklis_dialog_update.xml
Original file line number Diff line number Diff line change
@@ -1,68 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/default_padding">
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/default_padding">

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/logo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:maxHeight="120dp"
android:scaleType="center" />
android:id="@+id/logo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:maxHeight="120dp"
android:scaleType="center" />

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textAlignment="center"
android:textSize="20sp"
tools:text="Title" />
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textAlignment="center"
android:textSize="20sp"
tools:text="Title" />

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/version"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textAlignment="center"
tools:text="0.11.20" />
android:id="@+id/version"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textAlignment="center"
tools:text="0.11.20" />

<org.sufficientlysecure.htmltextview.HtmlTextView
android:id="@+id/changelog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:maxHeight="250dp"
tools:text="Bla Bla Bla" />
android:id="@+id/changelog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:clickable="false"
android:maxHeight="250dp"
tools:text="Bla Bla Bla" />

<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:orientation="horizontal"
android:weightSum="2">

<com.google.android.material.button.MaterialButton
android:id="@+id/fromApklis"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/update"
android:textAllCaps="true" />
android:id="@+id/fromApklis"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/update"
android:textAllCaps="true" />

<com.google.android.material.button.MaterialButton
android:id="@+id/download"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/download"
android:textAllCaps="true" />
android:id="@+id/download"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/download"
android:textAllCaps="true" />

</androidx.appcompat.widget.LinearLayoutCompat>

Expand Down
132 changes: 58 additions & 74 deletions apklisupdate/src/main/res/layout/apklis_fragment_update.xml
Original file line number Diff line number Diff line change
@@ -1,99 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/fragmentView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="@android:color/holo_blue_dark">
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/fragmentView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="@android:color/holo_blue_dark">

<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="@dimen/default_margin">

<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="@dimen/default_margin">
android:orientation="vertical"
android:padding="@dimen/default_padding">

<androidx.appcompat.widget.LinearLayoutCompat
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/logo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/default_padding">

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/logo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:maxHeight="120dp"
android:scaleType="center" />
android:layout_gravity="center"
android:gravity="center"
android:maxHeight="120dp"
android:scaleType="center" />

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textAlignment="center"
android:textSize="20sp"
tools:text="Title" />
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textAlignment="center"
android:textSize="20sp"
tools:text="Title" />

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/version"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textAlignment="center"
tools:text="0.11.20" />
android:id="@+id/version"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textAlignment="center"
tools:text="0.11.20" />

<org.sufficientlysecure.htmltextview.HtmlTextView
android:id="@+id/changelog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:maxHeight="250dp"
tools:text="Bla Bla
Bla" />
android:id="@+id/changelog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:maxHeight="250dp"
tools:text="Bla Bla (...) Bla" />

<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:orientation="horizontal"
android:weightSum="2">

<com.google.android.material.button.MaterialButton
android:id="@+id/fromApklis"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/update"
android:textAllCaps="true" />
android:id="@+id/fromApklis"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/update"
android:textAllCaps="true" />

<com.google.android.material.button.MaterialButton
android:id="@+id/download"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/download"
android:textAllCaps="true" />
android:id="@+id/download"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/download"
android:textAllCaps="true" />

</androidx.appcompat.widget.LinearLayoutCompat>

Expand Down
Loading

0 comments on commit 0e8de66

Please sign in to comment.