Skip to content

Commit

Permalink
Merge pull request #1 from ICTrust/dev
Browse files Browse the repository at this point in the history
Migrate Dev v1.2
  • Loading branch information
A-YATTA authored Oct 28, 2022
2 parents fea4a8c + c1cbd38 commit cc137d1
Show file tree
Hide file tree
Showing 18 changed files with 288 additions and 43 deletions.
11 changes: 6 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 30
compileSdkVersion 33
defaultConfig {
applicationId "ch.ictrust.pobya"
minSdkVersion 21
targetSdkVersion 30
targetSdkVersion 33
versionCode 1
versionName "1.0"
versionName "1.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
Expand All @@ -22,10 +22,11 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
buildToolsVersion '30.0.3'
namespace 'ch.ictrust.pobya'
}

dependencies {
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="ch.ictrust.pobya"
android:versionCode="1"
>

Expand All @@ -24,7 +23,7 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".activity.SplashActivity">
<activity android:name=".activity.SplashActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand All @@ -43,7 +42,8 @@

<receiver
android:name="ch.ictrust.pobya.Utillies.AppAdminReceiver"
android:permission="android.permission.BIND_DEVICE_ADMIN">
android:permission="android.permission.BIND_DEVICE_ADMIN"
android:exported="false">
<meta-data
android:name="android.app.device_admin"
android:resource="@xml/device_admin_receiver" />
Expand Down
20 changes: 18 additions & 2 deletions app/src/main/java/ch/ictrust/pobya/Utillies/DumpApps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,33 @@ class DumpApps(context: Context?, dumpSysApps: Boolean) {
private var dumpSystemApps = dumpSysApps
private var context = context!!

@RequiresApi(api = Build.VERSION_CODES.M)

fun getListApps(): MutableList<InstalledApp> {
permissions = getAllperms()
packageManager!!.packageInstaller.allSessions
listApps = ArrayList()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
installedPackages = packageManager!!.getInstalledPackages(
(PackageManager.GET_PERMISSIONS or PackageManager.GET_META_DATA or PackageManager.GET_SIGNING_CERTIFICATES)
)
} else {
installedPackages = packageManager!!.getInstalledPackages(
(PackageManager.GET_PERMISSIONS or PackageManager.GET_META_DATA or PackageManager.GET_SIGNATURES)
)
}
installedPackages = packageManager!!.getInstalledPackages(
(PackageManager.GET_PERMISSIONS or PackageManager.GET_META_DATA)
(PackageManager.GET_PERMISSIONS or PackageManager.GET_META_DATA or PackageManager.GET_SIGNING_CERTIFICATES)
)
for (pInfo: PackageInfo in (installedPackages as MutableList<PackageInfo>?)!!) {
val permissionsList: MutableList<PermissionModel> = ArrayList()
val reqPermissions = pInfo.requestedPermissions

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
println(pInfo.signingInfo.getApkContentsSigners())
} else {
println(pInfo.signatures)
}

var state: AppState = AppState.NORMAL
if (reqPermissions != null) state = getAppConfidence(pInfo)
if (!dumpSystemApps && isSystemPackage(pInfo) == 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import android.net.wifi.WifiManager;
import android.os.Build;
import android.provider.Settings;
import android.service.voice.VoiceInteractionService;
import android.telephony.TelephonyManager;
import android.view.autofill.AutofillManager;
import androidx.annotation.RequiresApi;
Expand Down Expand Up @@ -378,10 +379,10 @@ public void disableLocation(){

@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
public boolean isVoiceAssistanceEnabled() {
/** TODO: case of OnePlus that use "oneplus_default_voice_assist_picker_service" instead
* of "voice_interaction_service" and "assistant"
*/

/* if(Settings.Secure.getString(context.getContentResolver(), "enabled_input_methods") == "null")
return true;
*/
if ( android.provider.Settings.Secure.getString(context.getContentResolver(), "assistant") != null
&& !android.provider.Settings.Secure.getString(context.getContentResolver(), "assistant").isEmpty()) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import kotlinx.android.synthetic.main.activity_installed_apps.*
import java.lang.ref.WeakReference


@Suppress("OverrideDeprecatedMigration")
class InstalledAppsActivity : AppCompatActivity(), ItemClickListener {


Expand Down Expand Up @@ -126,13 +127,15 @@ class InstalledAppsActivity : AppCompatActivity(), ItemClickListener {
private var applicationList: MutableList<InstalledApp> = mutableListOf()


@Deprecated("Deprecated in Java")
@RequiresApi(Build.VERSION_CODES.M)
override fun doInBackground(vararg params: Void): MutableList<InstalledApp>? {
var dumpApps: DumpApps = DumpApps(appContext, dumpSysApps)
dumpApps.getListApps().also { applicationList = it }
return applicationList
}

@Deprecated("Deprecated in Java")
override fun onPreExecute() {
super.onPreExecute()
val activity = activityReference.get()
Expand All @@ -141,6 +144,7 @@ class InstalledAppsActivity : AppCompatActivity(), ItemClickListener {
}
}

@Deprecated("Deprecated in Java")
@RequiresApi(Build.VERSION_CODES.M)
override fun onPostExecute(result: MutableList<InstalledApp>) {
super.onPostExecute(result)
Expand Down
10 changes: 8 additions & 2 deletions app/src/main/java/ch/ictrust/pobya/activity/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte



@Deprecated("Deprecated in Java")
override fun onBackPressed() {
val drawerLayout: DrawerLayout = findViewById(R.id.drawer_layout)
if (drawerLayout.isDrawerOpen(GravityCompat.START)) {
Expand Down Expand Up @@ -153,6 +154,13 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
val intent = Intent(this, InstalledAppsActivity::class.java)
startActivity(intent)
}
R.id.nav_data_safety -> {
toolbarTitle.text = "Data Safety"
val transaction = supportFragmentManager.beginTransaction()
transaction.replace(R.id.container, DataSafetyPolicyFragment())
transaction.addToBackStack(null)
transaction.commit()
}
}
val drawerLayout: DrawerLayout = findViewById(R.id.drawer_layout)
drawerLayout.closeDrawer(GravityCompat.START)
Expand All @@ -174,7 +182,5 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
)
startActivityForResult(intent, RESULT_ENABLE)



}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ class WalkthroughActivity : AppCompatActivity() {
}
}

@Deprecated("Deprecated in Java")
override fun onBackPressed() {
// do something
return
}

fun addDotsIndicator(position: Int) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package ch.ictrust.pobya.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.webkit.WebView
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.GridLayoutManager
import ch.ictrust.pobya.R
import com.airbnb.lottie.LottieAnimationView
import kotlinx.android.synthetic.main.fragment_home.view.*

class DataSafetyPolicyFragment : Fragment() {

lateinit var wvDataSafetyPolicyFragment : WebView
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {

val view : View = inflater.inflate(R.layout.fragment_data_safety_policy, container, false)
view.categoryRecyclerView.apply {

wvDataSafetyPolicyFragment = view?.findViewById(R.id.wvDataSafetyPolicy)!!
wvDataSafetyPolicyFragment.loadUrl("file:///android_res/raw/policy.html")
}
return view

}
}
58 changes: 38 additions & 20 deletions app/src/main/java/ch/ictrust/pobya/fragment/MalwareScanFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import com.owl93.dpb.CircularProgressView
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.app_bar_main.*
import kotlinx.android.synthetic.main.app_bar_main.view.*
import kotlinx.android.synthetic.main.fragment_malware_scan.*
import org.w3c.dom.Text


class MalwareScanFragment : Fragment() {
Expand All @@ -42,6 +44,7 @@ class MalwareScanFragment : Fragment() {
lateinit var currentApp: TextView
lateinit var malwareScanRecyclerView : RecyclerView
lateinit var scanButton : Button
lateinit var malscanResultLotie: LottieAnimationView


@RequiresApi(Build.VERSION_CODES.M)
Expand All @@ -55,6 +58,7 @@ class MalwareScanFragment : Fragment() {
currentApp = view.findViewById(R.id.malware_app_scan_tv)
malwareScanRecyclerView = view.findViewById(R.id.malware_list_recyclerView)
scanButton = view.findViewById(R.id.scanHome)
malscanResultLotie = view.findViewById(R.id.malware_result_animation)

currentApp.text = ""
lottieScanAnimation.visibility = View.GONE
Expand All @@ -63,7 +67,7 @@ class MalwareScanFragment : Fragment() {
malwareScanWheelProgress.progress = 0F
var malwareAsyncTask = MalwareScanAsyncTask(
activity as MainActivity, lottieScanAnimation,
malwareScanWheelProgress, currentApp, malwareScanRecyclerView, scanButton
malwareScanWheelProgress, currentApp, malwareScanRecyclerView, scanButton, malscanResultLotie
)

malwareScanWheelProgress.setOnClickListener(View.OnClickListener {
Expand All @@ -74,7 +78,8 @@ class MalwareScanFragment : Fragment() {
} else {
malwareAsyncTask = MalwareScanAsyncTask(
activity as MainActivity, lottieScanAnimation,
malwareScanWheelProgress, currentApp, malwareScanRecyclerView, scanButton
malwareScanWheelProgress, currentApp, malwareScanRecyclerView, scanButton,
malscanResultLotie
).execute() as MalwareScanAsyncTask
}

Expand All @@ -90,7 +95,8 @@ class MalwareScanFragment : Fragment() {
malwareScanWheelProgress: CircularProgressView,
currentApp: TextView,
malwareRecyclerView: RecyclerView,
scanButton: Button
scanButton: Button,
malscanResultLotie: LottieAnimationView
) : AsyncTask<Void, Void, MutableList<InstalledApp>>() {

private var appContext : Context = context
Expand All @@ -103,9 +109,11 @@ class MalwareScanFragment : Fragment() {
private lateinit var installedAppsAdapter: InstalledAppsAdapter
private var malwarePackgesApps: MutableList<InstalledApp> = mutableListOf()
private var scanButton : Button = scanButton
private var malscanResult : LottieAnimationView = malscanResultLotie



@Deprecated("Deprecated in Java")
@RequiresApi(Build.VERSION_CODES.M)
override fun doInBackground(vararg params: Void): MutableList<InstalledApp>? {
var malwarePackageListString : ArrayList<String> = ArrayList()
Expand Down Expand Up @@ -170,6 +178,7 @@ class MalwareScanFragment : Fragment() {
return false
}

@Deprecated("Deprecated in Java")
override fun onPreExecute() {
super.onPreExecute()
//lottieAnimation.visibility = View.VISIBLE
Expand All @@ -186,6 +195,7 @@ class MalwareScanFragment : Fragment() {
}
}

@Deprecated("Deprecated in Java")
@SuppressLint("Range")
@RequiresApi(Build.VERSION_CODES.M)
override fun onPostExecute(result: MutableList<InstalledApp>) {
Expand All @@ -196,26 +206,34 @@ class MalwareScanFragment : Fragment() {
currentAppScan.text = ""
scanButton.text = appContext.getString(R.string.done)

installedAppsAdapter = InstalledAppsAdapter(malwarePackgesApps, appContext)
installedAppsAdapter.setClickListener(object : ItemClickListener {
override fun onItemClick(position: Int) {
val intent = Intent(
appContext.applicationContext,
AppDetailActivity::class.java
if (malwarePackgesApps.size == 0) {
malscanResult.animate()
malscanResult.visibility = View.VISIBLE
malscanResult.progress = 0F
malscanResult.playAnimation()
} else {
installedAppsAdapter = InstalledAppsAdapter(malwarePackgesApps, appContext)
installedAppsAdapter.setClickListener(object : ItemClickListener {
override fun onItemClick(position: Int) {
val intent = Intent(
appContext.applicationContext,
AppDetailActivity::class.java
)
intent.putExtra("app", malwarePackgesApps[position])
appContext.startActivity(intent)
}
})
malwareRecyclerView.setLayoutManager(LinearLayoutManager(appContext))
malwareRecyclerView.apply {
layoutManager = LinearLayoutManager(
this.context,
LinearLayoutManager.VERTICAL,
false
)
intent.putExtra("app", malwarePackgesApps[position])
appContext.startActivity(intent)
adapter = installedAppsAdapter
}
})
malwareRecyclerView.setLayoutManager(LinearLayoutManager(appContext))
malwareRecyclerView.apply {
layoutManager = LinearLayoutManager(
this.context,
LinearLayoutManager.VERTICAL,
false
)
adapter = installedAppsAdapter
}

}
}

Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/drawable-v21/ic_baseline_privacy_tip_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M12,1L3,5v6c0,5.55 3.84,10.74 9,12c5.16,-1.26 9,-6.45 9,-12V5L12,1L12,1zM11,7h2v2h-2V7zM11,11h2v6h-2V11z"/>
</vector>
14 changes: 14 additions & 0 deletions app/src/main/res/layout/fragment_data_safety_policy.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragment.DataSafetyPolicyFragment">

<WebView
android:id="@+id/wvDataSafetyPolicy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/text_margin"
android:text="" />
</androidx.core.widget.NestedScrollView>
Loading

0 comments on commit cc137d1

Please sign in to comment.