Skip to content

Commit

Permalink
Switch to hf
Browse files Browse the repository at this point in the history
	Ship debug android build
	Allow microphone interaction
  • Loading branch information
posix4e committed Apr 7, 2023
1 parent 6a81f0b commit 0979107
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/android-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.main_project_module }}/build/outputs/apk/ta//co//release/app-release-unsigned.apk # Update this with the correct APK path
asset_path: ${{ env.main_project_module }}/build/outputs/apk/debug/app-debug.apk # Update this with the correct APK path
asset_name: app-release-unsigned.apk
asset_content_type: application/vnd.android.package-archive
9 changes: 7 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />

<uses-permission android:name="android.permission.MICROPHONE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-feature android:name="android.hardware.audio.low_latency" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-feature android:name="android.hardware.audio.pro" />
<uses-feature android:name="android.hardware.microphone"/>
<application
android:hardwareAccelerated="true"
android:icon="@mipmap/gpt_icon"
Expand Down
25 changes: 13 additions & 12 deletions app/src/main/java/com/matthaigh27/chatgptwrapper/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,27 @@ package com.matthaigh27.chatgptwrapper

import android.annotation.SuppressLint
import android.app.Activity
import android.content.Intent
import android.graphics.Color
import android.os.Build
import android.os.Bundle
import android.view.WindowManager
import android.webkit.PermissionRequest
import android.webkit.WebChromeClient
import android.webkit.WebView
import android.webkit.WebViewClient
import android.window.OnBackInvokedDispatcher
import com.matthaigh27.chatgptwrapper.databinding.ActivityMainBinding


class MainActivity : Activity() {
private val userAgent =
"Mozilla/5.0 (Linux; Android 10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.5563.57 Mobile Safari/537.36"
private val chatUrl = "https://chat.openai.com/"
private val chatUrl = "https://posix4e-langchainback2.hf.space/"
private lateinit var binding: ActivityMainBinding
private lateinit var webView: WebView

@SuppressLint("SetJavaScriptEnabled")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)



binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
webView = binding.webView
Expand All @@ -49,15 +46,18 @@ class MainActivity : Activity() {
webView.settings.domStorageEnabled = true
webView.settings.javaScriptEnabled = true
webView.webViewClient = WebViewClient()

webView.setWebChromeClient(object : WebChromeClient() {
override fun onPermissionRequest(request: PermissionRequest) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
request.grant(request.resources)
}
}
})
webView.loadUrl(chatUrl)
// val intent = Intent(Intent.ACTION_MAIN)
// intent.addCategory(Intent.CATEGORY_HOME)
// intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
// startActivity(intent)
// finish()

}


@Deprecated("Deprecated in Java")
override fun onBackPressed() {
@Suppress("DEPRECATION")
Expand All @@ -66,4 +66,5 @@ class MainActivity : Activity() {
else
super.onBackPressed()
}

}

0 comments on commit 0979107

Please sign in to comment.