Giter Club home page Giter Club logo

input-samples's Introduction

Android Input Samples Repository

This repository contains a set of individual Android Studio projects to help you get started writing/understanding input in Android.

input-samples's People

Contributors

cedricferry avatar codingjeremy avatar jimmithy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

input-samples's Issues

Not working on browser

Hi there, I just try this sample on Android P Beta but it's not working on browsers. Tested on chrome, chrome beta, Microsoft Edge.

Cant support the FB messenger

I tried it in FB Messenger and I found that the judgement is acceptable but the doCommit is wrong.
So the FB could not receive the photo I shared.

Autofill doesn't work on Android 10/Flutter/WebView

I've created a simple flutter app using webview_flutter plugin. I open a web page and no autofill suggestions are shown. While the same page works if hosted in webview in a native app. I suppose it's a problem with flutter somewhere, but could you check this log and see if it is obvious what's going on?
Below is the log filtered by "autofill" and after i click on a field that shuld work.

2021-10-20 11:50:31.197 30038-30038/com.example.test_google_webview V/AutofillManager: requestHideFillUi(null): anchor = null
2021-10-20 11:50:31.639 30038-30038/com.example.test_google_webview V/AutofillManager: not ignoring notifyViewEntered(flags=0, view=1073741824:65539, state UNKNOWN, enteredIds=null
2021-10-20 11:50:31.639 30038-30038/com.example.test_google_webview V/AutofillManager: startSessionLocked(): id=1073741824:65539, bounds=Rect(56, 913 - 700, 983), value=null, flags=0, state=UNKNOWN, compatMode=false, enteredIds=null
2021-10-20 11:50:31.640 699-2424/? V/AutofillManagerServiceImpl: startSession(): token=Token{de0943 ActivityRecord{1fccef2 u0 com.example.test_google_webview/.MainActivity t24179}}, flags=0
2021-10-20 11:50:31.642 699-2424/? V/AutofillSession: updateLocked(): id=1073741824:65539, action=START_SESSION, flags=0
2021-10-20 11:50:31.642 699-2424/? V/AutofillSession: Creating viewState for 1073741824:65539
2021-10-20 11:50:31.642 699-2424/? V/AutofillSession: Requesting structure for request #1 ,requestId=13, flags=0
2021-10-20 11:50:31.673 699-3352/? V/AutofillSession: New structure for requestId 13: android.app.assist.AssistStructure@b0b3b58
2021-10-20 11:50:31.676 699-3352/? V/AutofillSession: fillContextWithAllowedValuesLocked(): no node for 1073741824:65539
2021-10-20 11:50:31.895 699-724/? V/AutofillSession: canceling session -1731086303 when server returned null
2021-10-20 11:50:31.895 699-724/? V/AutofillSession: removeSelfLocked(): null
2021-10-20 11:50:31.896 699-724/? V/AutofillSession: destroyLocked(): logging 1 requests
2021-10-20 11:50:31.896 699-715/? D/AutofillUI: destroySaveUiUiThread(): already destroyed
2021-10-20 11:50:31.897 30038-30038/com.example.test_google_webview V/AutofillManager: notifyNoFillUi(): sessionId=-1731086303, autofillId=1073741824:65539, sessionFinishedState=2
2021-10-20 11:50:31.897 30038-30038/com.example.test_google_webview V/AutofillManager: setSessionFinished(): from ACTIVE to FINISHED
2021-10-20 11:50:36.899 699-724/? V/RemoteFillService: Not handling operation as service for ComponentInfo{com.google.android.gms/com.google.android.gms.autofill.service.AutofillService} is already destroyed

FileProvider uses the wrong authority so it cannot share files

The keyboard wont work because the FileProvider authority in the java file doesn't match the AndroidManifest.xml.

From AndroidManifest: android:authorities="com.example.android.commitcontent.ime.inputcontent"

From ImageKeyboard.java:
private static final String AUTHORITY = "com.example.android.supportv13.sampleime.inputcontent";

Add Postal Code to the Credit Card Check Out Sample

I would like to have a sample credit card check out with a postal code field either by creating a new sample or adding the postal code to the existing one.

This is a case that we want to handle, I can create a PR if it's ok for you.

Default Activity not found

Since there is no activity defined in the manifest, getting error in Android studio.

Error running app:
Default Activity not found

Question: Usage of validatePackageName()

Code and inline comments are clear to understand the intention of this method!

Update comments to include what would have happened incase of absence of this method

AutofillFramework sample needs update to support Flamingo and later studio versions

Steps
  1. Open AutoFillFramework sample
  2. Click on link upgrade gradle wrapper to 7.2 and re-import project
Actual
  1. When re-import happens project suck at re-download dependencies error page and clicking on it will not change anything.
  2. Close and re-opening project will also not work
Unable to find method ''org.gradle.api.file.DirectoryProperty org.gradle.api.file.ProjectLayout.directoryProperty(org.gradle.api.provider.Provider)''
'org.gradle.api.file.DirectoryProperty org.gradle.api.file.ProjectLayout.directoryProperty(org.gradle.api.provider.Provider)'

Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)

Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.

Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
Workaround
  1. Open Application build.gradle and update the AGP to classpath 'com.android.tools.build:gradle:8.0.0-rc01' and gradle wrapper properties distribution url to distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
  2. Add the mavenCentral() repo in the Application build.gradle
  3. Add package namespace in the build.gradle for Application and afservice
  4. Gradle Sync > Sync will be successful and able to deploy

does not install for android 5 and higher

When, I install it to android 4x, I can see CommitContentSampleIME and choise it as default input method

When I install this keyboar on devices which run android 5+, CommitContentSampleIME does not appears in input settings and thus I cannot select it (but it is present in installed apps)

What does the debug_service file do?

What if I want the service to support other third-party browsers?

Because I found that some third-party browsers cannot trigger the autofill service correctly。

Looking forward to your answer!Thanks.

Whatsapp is not supported

Hi,

I'm developing a custom keyboard that have to send images to Messenger and Whatsapp conversasions. So, I called the function isCommitContentSupported(...,MIME_TYPE_PNG) on Whatsapp and returned false, and a called the same function on Messenger app and returned true. The Commit Content is not supported on Whatsapp.

Anybody can help? There is an alternative?

compatibility issue when migrating to androidx

This code stop working on devices below 25 when I migrate to androidx recently.
Device info: Sony xperia M5 - Android 6.0.0
Those code block

import android.support.v13.view.inputmethod.EditorInfoCompat;
import android.support.v13.view.inputmethod.InputConnectionCompat;
import android.support.v13.view.inputmethod.InputContentInfoCompat;

are replaced with

import androidx.core.view.inputmethod.EditorInfoCompat;
import androidx.core.view.inputmethod.InputConnectionCompat;
import androidx.core.view.inputmethod.InputContentInfoCompat;

Is it androidx issue?
Thanks,
image

Autofill Framework functionality is castrated on Android Emulator when using in Chrome browser

I am using Android Emulator, so maybe this can be the reason of such behavior.

Autofill service being used: Basic Heuristic Autofill Service
Emulator being used: Nexus 6P API 28 (Android 9, API 28)

Steps to reproduce:

  1. Open Google Chrome in emulator.
  2. Click on URL bar -> BasicService::onFillRequest is triggered. This is OK.
  3. Go to any website (e.g. instagram.com).
  4. Click login.
  5. Focus in some field (e.g. email or password) -> BasicService::onFillRequest is NOT triggered. This is NOT OK.

Expected result:

  1. By clicking on URL bar, BasicService::onFillRequest is triggered. This is already the case, so it's ok.
  2. By clicking on any website field, BasicService::onFillRequest is triggered. This is not the case, so the behavior is wrong in this case.

What can be the reason of such behavior? Am I missing something or is it a bug of Android Autofill Framework? If it is a bug, then is there some workaround that I can use to make Autofill Framework to work properly? Maybe different emulator would work? If so, then which emulator should I use to test this feature properly?

NullPointException

I use emulator which api is 25 to run this sample,when select "insert GIF",the sample crashed.
the error StackTrace:
java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)' on a null object reference
at android.support.v4.content.FileProvider.parsePathStrategy(FileProvider.java:583)
at android.support.v4.content.FileProvider.getPathStrategy(FileProvider.java:557)
at android.support.v4.content.FileProvider.getUriForFile(FileProvider.java:399)
at com.example.android.commitcontent.ime.ImageKeyboard.doCommitContent(ImageKeyboard.java:97)
at com.example.android.commitcontent.ime.ImageKeyboard.access$100(ImageKeyboard.java:49)
at com.example.android.commitcontent.ime.ImageKeyboard$1.onClick(ImageKeyboard.java:206)
at android.view.View.performClick(View.java:5637)
at android.view.View$PerformClick.run(View.java:22429)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

BasicGestureDetect: Task :Application:lint FAILED: This custom view should extend android.support.v7.widget.AppCompatTextView instead [AppCompatCustomView]

Mac-mini:BasicGestureDetect anka$ java -version
openjdk version "1.8.0_242-release"
OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
OpenJDK 64-Bit Server VM (build 25.242-b3-6222593, mixed mode)
Mac-mini:BasicGestureDetect anka$ ./gradlew check

> Task :Application:lint FAILED
Ran lint on variant debug: 18 issues found
Ran lint on variant release: 18 issues found
Wrote HTML report to file:///Users/anka/AndroidStudioProjects/BasicGestureDetect/Application/build/reports/lint-results.html
Wrote XML report to file:///Users/anka/AndroidStudioProjects/BasicGestureDetect/Application/build/reports/lint-results.xml

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':Application:lint'.
> Lint found errors in the project; aborting build.
  
  Fix the issues identified by lint, or add the following to your build script to proceed with errors:
  ...
  android {
      lintOptions {
          abortOnError false
      }
  }
  ...
  
  Errors found:
  
  /Users/anka/AndroidStudioProjects/BasicGestureDetect/Application/src/main/java/com/example/android/common/logger/LogView.java:25: Error: This custom view should extend android.support.v7.widget.AppCompatTextView instead [AppCompatCustomView]
  public class LogView extends TextView implements LogNode {
                               ~~~~~~~~
  


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 14s
24 actionable tasks: 1 executed, 23 up-to-date

EditorInfoCompat.getContentMimeTypes(editorInfo);

when running to this method, it always returns an empty array:

private boolean isCommitContentSupported(
@nullable EditorInfo editorInfo, @nonnull String mimeType) {
if (editorInfo == null) {
return false;
}

    final InputConnection ic = getCurrentInputConnection();
    if (ic == null) {
        return false;
    }

    if (!validatePackageName(editorInfo)) {
        return false;
    }

    final String[] supportedMimeTypes = EditorInfoCompat.getContentMimeTypes(editorInfo);// Here is the empty array, and results in false return 


    for (String supportedMimeType : supportedMimeTypes) {
        if (ClipDescription.compareMimeTypes(mimeType, supportedMimeType)) {
            return true;
        }
    }
    return false;
}

I'm running on an Android 8 device

WebView sample doesn't work

The WebView example doesn't trigger any OnFill requests.
Tested on Pixel C (Android 8.0.0 - OPR6.170623.010).
Build tool version: 26.0.1

Are WebViews actually supported? Any timeline about Chrome Mobile support?

getWebDomain() function always returns null in Android AutoFill service

Hi folks,
I’m unable to get the domain name for the chrome webpage with which the autofill service sample is interacting. It works fine, but I need to know what is the webpage's domain name raised onFillRequest function.
I tested DebugService, and here I see the addAutofillableFields function with ViewNode parameter. It looks like node.getWebDomain() should return domain name from this page, but it always returns null.
How can I get web domain in other ways?
I tested login.yahoo.com page.

Thanks!

not working onCommitContent

not called onCommitContent of an interface OnCommitContentListener:

`EditText exitText = new EditText(this) {
@OverRide
public InputConnection onCreateInputConnection(EditorInfo editorInfo) {
final InputConnection ic = super.onCreateInputConnection(editorInfo);
EditorInfoCompat.setContentMimeTypes(editorInfo, mimeTypes);
final InputConnectionCompat.OnCommitContentListener callback = new InputConnectionCompat.OnCommitContentListener() {

                @Override
                public boolean onCommitContent(InputContentInfoCompat inputContentInfo, int flags, Bundle opts) {
                    return MainActivity.this.onCommitContent(inputContentInfo, flags, opts, mimeTypes);
                }
            };
            return InputConnectionCompat.createWrapper(ic, editorInfo, callback);
        }
    };`

` private boolean onCommitContent(InputContentInfoCompat inputContentInfo,
int flags, Bundle opts, String[] contentMimeTypes) {
Log.d("tagger", "onCommitContent inside");
try {
if (mCurrentInputContentInfo != null) {
mCurrentInputContentInfo.releasePermission();
}
} catch (Exception e) {
Log.e(TAG, "InputContentInfoCompat#releasePermission() failed.", e);
} finally {
mCurrentInputContentInfo = null;
}
mWebView.loadUrl("about:blank");
mMimeTypes.setText("");
mContentUri.setText("");
mLabel.setText("");
mLinkUri.setText("");
mFlags.setText("");

    boolean supported = false;
    for (final String mimeType : contentMimeTypes) {
        if (inputContentInfo.getDescription().hasMimeType(mimeType)) {
            supported = true;
            break;
        }
    }
    return supported && onCommitContentInternal(inputContentInfo, flags);
}`

what I can do in this case?

Failed to find Build Tools revision 25.0.0 rc1

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25 rc1"
defaultConfig {
applicationId "com.example.android.android.sampleapp"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:support-v13:25.0.0'
testCompile 'junit:junit:4.12'
}

and this line: buildToolsVersion "25 rc1"
produce an error - packages unavailable

How does Credit Card autofill actually work?

Hi, I am currently trying to use credit card autofill in my Credit Cart Bill Payment page. In my case, I only need the credit card number. So in my first poc, I use a single field with autofillHints attr set with AUTOFILL_HINT_CREDIT_CARD_NUMBER. But the autofill recommendation on the keyboard didn't show at all.

After some checking, seems like a single field is not sufficient. I also need another view present in the layout, that is a view with autofillHints attr set with AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE or portions of the expiration date, and they have to be visible (width/height != 0, visibility == visible). Idk why, did some experiment and seems so.

But I don't need the expiration date at all. What I can do right now is by setting the height and width to 0,01dp, so the field doesn't appear to the users.

My question is, do I really need expire date field to be able to use the autofill feature? or can I achieve that with only a single field (creditCardNumber)?

Autofill Service for the sample app cannot be added as the autofill service on Android 12 or Android 13

On Android 12 and Android 13, the sample app cannot be added as the autofill service. On navigating to Settings -> Passwords & Accounts and then clicking on Google (which by the way is the way to change the Autofill Service), there is no Autofill Sample showing up as an option.

This results in the autofill sample not being of use as one cannot see any autofill in the app at all.

P.S. I have not tried < Android 12.

Link uri is not generating for Samsung keybaord

Hi folks,
I am using samsung s8 device to send the default keyboard gif images to the server. But I am not able to get the link uri from the samsung s8 device. I am getting link uri as null.
Can anybody please do needful?

Providing a Uri Suggestion for Autofill

Hi there,
I'm writing an app that accesses a user's server from their provided Uri. To authenticate, I show a Credential Dialog.
How could I associate the uri of their server with the EditText for Autofill?

Currently I'm using the LastPass Fill Helper, (Pre-Oreo), and it tries to search for logins using my App's PackageName, which obviously won't return any helpful results.

Obviously, I can't do any App associations because the Server is not mine and out of my control.

Top fans to blun

This is secure for you and is made for your entertainment, so please enjoy, thank you.

Right Click on physical mouse...

If I want to play a game which requires right click to place a block, I would like to be able to do so. Unfortunately, Right Click is basically wired to KEYCODE_BACK. It would be nice for there to be an option to turn off this right click as back, either in normal settings, accesibility or even developer options. maybe make it a toggle or if needed, a list of possible inputs, like home, multitask, vol up and down, pow, back, context menu, or it's own keycode. Keyboards have A-Z, 0-9, etc. Give right click it's own key please

Not working at all for many cases

  1. It is not working when I am testing the sample app with Google Autofill services, It says it does not support
    2.Edittext is not editable and can't save the data for autofill services. It says, save not supported.

It would be much better if some one check the source code and provide cleaner code. It is not standard for Google to provide such as spaghetti code.

Not enough use case example such as custom view and formatting, e.g phone formatting and credit cards and etc.

Automatic Autofill does not work after updating to AndroidX

Using the AutofillFramework example code works well. Using the RecyclerViewActivity, and clicking on the name field will show a box with my name that I can click to fill that field.

After days of trying to find why it doesn't work in my own app, I soon realised that the sample app isn't using AndroidX.

Just opening a fresh version of the AutofillFramework and migrating it to AndroidX using Android Studio will make the automatic autofill stop working. Long pressing the text field and pressing autofill still works, but what user will use that feature?

I have tested both on a Google Pixel running Android 10 and a OnePlus 8 Pro running Android 11.

Please let me know if I need to provide more information.

README is wrong for AutofillFrameworkKotlin and AutofillFramework

I tried installing the AutofillFramework sample application but could not set the service as the autofill service under Settings -> System -> Languages & input -> Autofill service. I attempted this on four different emulators, API level 26 through 29.

After that I uninstalled all the AutofillFramework sample applications and installed the AutofillFrameworkKotlin sample application on the same four emulators. I was able to correctly set these as the autofill service. The README led me to believe that the AutofillFrameworkKotlin sample app wouldn’t work and that the AutofillFramework sample app would, but that was incorrect.

Debugging on Android 6 API 23

When I add the keyboard and switch it to use on SMS mode on Android 6 API 23
does not commit content. Hence dont see the image getting posted
on debugging i see
EditorInfoCompat.getContentMimeTypes(editorInfo) always NULL hence
supported = true; does not happen.

Do you know why it wont work on API 23 but works on API 25 ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.