-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
211 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
app/src/main/java/com/ethosa/ktc/college/ActualAppVersion.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.ethosa.ktc.college | ||
|
||
/** | ||
* JSON: | ||
* { "actual_version": [0, 6, 0] } | ||
*/ | ||
data class ActualAppVersion( | ||
val actual_version: List<Int>, | ||
val download_url: String | ||
) { | ||
fun isActual(): Boolean { | ||
for (i in 0..2) { | ||
if (actual_version[i] > CollegeApi.VERSION[i]) { | ||
return false | ||
} | ||
} | ||
return true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ethosa/ktc/utils/SpacingItemDecoration.kt → ...tc/ui/decoration/SpacingItemDecoration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../com/ethosa/ktc/utils/AlbumPhotoDialog.kt → .../ethosa/ktc/ui/dialog/AlbumPhotoDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.ethosa.ktc.utils | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import android.net.Uri | ||
import android.os.Environment | ||
import com.ethosa.ktc.college.CollegeCallback | ||
import okhttp3.Call | ||
import okhttp3.OkHttpClient | ||
import okhttp3.Request | ||
import okhttp3.Response | ||
import java.io.File | ||
|
||
|
||
class AppUpdater( | ||
private val context: Context | ||
) { | ||
fun update(url: String) { | ||
val path = Environment.getDownloadCacheDirectory().toString() + "/KTC/" | ||
val req = Request.Builder() | ||
.url(url) | ||
.get() | ||
.build() | ||
OkHttpClient().newCall(req).enqueue(object : CollegeCallback { | ||
override fun onResponse(call: Call, response: Response) { | ||
val file = File(path) | ||
file.mkdirs() | ||
val apkFile = File(file, "actual_app.apk") | ||
val output = apkFile.outputStream() | ||
val input = response.body?.byteStream() | ||
val buffer = ByteArray(1024) | ||
var len1: Int | ||
while (input!!.read(buffer).also { len1 = it } != -1) { | ||
output.write(buffer, 0, len1) | ||
} | ||
output.close() | ||
input.close() | ||
|
||
val install = Intent(Intent.ACTION_VIEW) | ||
.setData(Uri.parse(path + "app.apk")) | ||
.setType("application/android.com.app") | ||
context.startActivity(install) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.ethosa.ktc.utils | ||
|
||
import android.Manifest | ||
import android.app.Activity | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.content.pm.PackageManager | ||
import android.net.Uri | ||
import android.os.Build | ||
import android.os.Environment | ||
import android.provider.Settings | ||
import androidx.core.app.ActivityCompat | ||
import androidx.core.content.ContextCompat | ||
|
||
|
||
class Permissions { | ||
fun hasPermissions(context: Context?): Boolean { | ||
return when { | ||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.R -> { | ||
Environment.isExternalStorageManager() | ||
} | ||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M -> { | ||
(ContextCompat.checkSelfPermission(context!!, Manifest.permission.WRITE_EXTERNAL_STORAGE) | ||
== PackageManager.PERMISSION_GRANTED) | ||
} | ||
else -> { | ||
true | ||
} | ||
} | ||
} | ||
|
||
fun requestPermissions(activity: Activity, requestCode: Int) { | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { | ||
try { | ||
val intent = Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION) | ||
intent.addCategory("android.intent.category.DEFAULT") | ||
intent.data = Uri.parse(String.format("package:%s", activity.packageName)) | ||
activity.startActivityForResult(intent, requestCode) | ||
} catch (e: Exception) { | ||
val intent = Intent() | ||
intent.action = Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION | ||
activity.startActivityForResult(intent, requestCode) | ||
} | ||
} else { | ||
ActivityCompat.requestPermissions( | ||
activity, arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), | ||
requestCode | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.