If it is the Google Play version, the update check will not be displayed within 2 days after update.
This commit is contained in:
@@ -5,6 +5,7 @@ import android.content.Intent
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import android.view.View
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
@@ -22,6 +23,7 @@ import com.v2ray.ang.extension.toastSuccess
|
|||||||
import com.v2ray.ang.handler.MmkvManager
|
import com.v2ray.ang.handler.MmkvManager
|
||||||
import com.v2ray.ang.handler.SpeedtestManager
|
import com.v2ray.ang.handler.SpeedtestManager
|
||||||
import com.v2ray.ang.handler.UpdateCheckerManager
|
import com.v2ray.ang.handler.UpdateCheckerManager
|
||||||
|
import com.v2ray.ang.util.AppManagerUtil
|
||||||
import com.v2ray.ang.util.Utils
|
import com.v2ray.ang.util.Utils
|
||||||
import com.v2ray.ang.util.ZipUtil
|
import com.v2ray.ang.util.ZipUtil
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@@ -103,6 +105,14 @@ class AboutActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//If it is the Google Play version, not be displayed within 2 days after update
|
||||||
|
if (Utils.isGoogleFlavor()) {
|
||||||
|
val lastUpdateTime = AppManagerUtil.getLastUpdateTime(this)
|
||||||
|
val currentTime = System.currentTimeMillis()
|
||||||
|
if ((currentTime - lastUpdateTime) < 2 * 24 * 60 * 60 * 1000L) {
|
||||||
|
binding.layoutCheckUpdate.visibility = View.GONE
|
||||||
|
}
|
||||||
|
}
|
||||||
binding.layoutCheckUpdate.setOnClickListener {
|
binding.layoutCheckUpdate.setOnClickListener {
|
||||||
checkForUpdates(binding.checkPreRelease.isChecked)
|
checkForUpdates(binding.checkPreRelease.isChecked)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,4 +33,8 @@ object AppManagerUtil {
|
|||||||
|
|
||||||
return@withContext apps
|
return@withContext apps
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getLastUpdateTime(context: Context): Long =
|
||||||
|
context.packageManager.getPackageInfo(context.packageName, 0).lastUpdateTime
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ import android.webkit.URLUtil
|
|||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import com.v2ray.ang.AppConfig
|
import com.v2ray.ang.AppConfig
|
||||||
import com.v2ray.ang.AppConfig.ANG_PACKAGE
|
|
||||||
import com.v2ray.ang.AppConfig.LOOPBACK
|
import com.v2ray.ang.AppConfig.LOOPBACK
|
||||||
|
import com.v2ray.ang.BuildConfig
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.net.ServerSocket
|
import java.net.ServerSocket
|
||||||
import java.net.URLDecoder
|
import java.net.URLDecoder
|
||||||
@@ -486,7 +486,14 @@ object Utils {
|
|||||||
*
|
*
|
||||||
* @return True if the package is Xray, false otherwise.
|
* @return True if the package is Xray, false otherwise.
|
||||||
*/
|
*/
|
||||||
fun isXray(): Boolean = ANG_PACKAGE.startsWith("com.v2ray.ang")
|
fun isXray(): Boolean = BuildConfig.APPLICATION_ID.startsWith("com.v2ray.ang")
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if it is the Google Play version.
|
||||||
|
*
|
||||||
|
* @return True if the package is Google Play, false otherwise.
|
||||||
|
*/
|
||||||
|
fun isGoogleFlavor(): Boolean = BuildConfig.FLAVOR == "playstore"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -127,24 +127,23 @@
|
|||||||
android:layout_height="@dimen/image_size_dp24"
|
android:layout_height="@dimen/image_size_dp24"
|
||||||
app:srcCompat="@drawable/ic_check_update_24dp" />
|
app:srcCompat="@drawable/ic_check_update_24dp" />
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingStart="@dimen/padding_spacing_dp16"
|
android:orientation="vertical"
|
||||||
android:text="@string/update_check_for_update"
|
android:paddingStart="@dimen/padding_spacing_dp16">
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Subhead" />
|
|
||||||
|
|
||||||
<LinearLayout
|
<TextView
|
||||||
android:layout_width="0dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:text="@string/update_check_for_update"
|
||||||
android:gravity="center|end"
|
android:textAppearance="@style/TextAppearance.AppCompat.Subhead" />
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.SwitchCompat
|
<androidx.appcompat.widget.SwitchCompat
|
||||||
android:id="@+id/check_pre_release"
|
android:id="@+id/check_pre_release"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/padding_spacing_dp16"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:text="@string/update_check_pre_release"
|
android:text="@string/update_check_pre_release"
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||||
|
|||||||
Reference in New Issue
Block a user