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 6238bd7
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 14 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
21 changes: 20 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>

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

<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.Manifest.permission.RECORD_AUDIO"/>
<uses-feature android:name="android.hardware.camera"/>
<uses-feature android:name="android.hardware.camera.autofocus"/>
<uses-feature android:name="android.hardware.camera.front"/>
<uses-feature android:name="android.hardware.camera.front.autofocus"/>
<uses-feature android:name="android.hardware.sensor.accelerometer" android:required="true"/>
<uses-feature android:name="android.hardware.sensor.gyroscope" android:required="true"/>
<uses-feature android:name="android.software.vr.mode" android:required="true"/>
<uses-feature android:name="android.hardware.vr.high_performance" android:required="true"/>

<application
android:hardwareAccelerated="true"
Expand Down
30 changes: 18 additions & 12 deletions app/src/main/java/com/matthaigh27/chatgptwrapper/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
package com.matthaigh27.chatgptwrapper

import android.Manifest
import android.annotation.SuppressLint
import android.annotation.TargetApi
import android.app.Activity
import android.content.Intent
import android.content.Context
import android.content.pm.PackageManager
import android.graphics.Color
import android.os.Build
import android.os.Bundle
import android.util.Log
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 androidx.core.app.ActivityCompat
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 +52,17 @@ class MainActivity : Activity() {
webView.settings.domStorageEnabled = true
webView.settings.javaScriptEnabled = true
webView.webViewClient = WebViewClient()

webView.webChromeClient = object : WebChromeClient() {
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
override fun onPermissionRequest(request: PermissionRequest) {
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 +71,5 @@ class MainActivity : Activity() {
else
super.onBackPressed()
}

}

0 comments on commit 6238bd7

Please sign in to comment.