LanguagePack icon indicating copy to clipboard operation
LanguagePack copied to clipboard

Dependency on AnySoftKeyboard apk

Open kyraha opened this issue 10 years ago • 6 comments

Oftentimes end-users install a language pack without reading the instructions and get disappointed that the app is not working right away. Would it be possible to add a dependency into the language pack apk so it'd require installing ASK and maybe even help to find it and ask if it's OK to install ASK automatically? Thank you.

kyraha avatar Dec 15 '15 16:12 kyraha

Judging from many comments on many packs in the play store, this problem seems to arise pretty often and it leads to unnecessary downgrades in the rates. It seems, it could only be possible to solve it with a solution similar to: https://stackoverflow.com/questions/7724579/how-to-make-an-android-app-that-depends-on-another-app It would be necessary to include this code in an activity, but currently the only actual runnable code in a language pack is the PackBroadcastReceiver. So we'd need to include an activity, which would in turn be able to be started somehow, I guess via a launcher icon? And this icon should of course vanish, as soon as the base app is installed ... sounds a bit complicated. Or maybe we could have a kind of "blank" keyboard fragment, which would only show the error. but how to hide this from the android system, as soon as the base app is installed? @menny what do you think?

friesenkiwi avatar Mar 03 '17 09:03 friesenkiwi

@menny what do you think on this?

friesenkiwi avatar Jul 10 '17 09:07 friesenkiwi

@friesenkiwi We should do this.

Shouldn't be too hard to do, the only thing I'm worried about is the icon in the launcher - it just sits there, doing nothing.

menny avatar Jul 27 '17 03:07 menny

@menny OK, so you are open to adding a DummyActivity in each pack?

I looked around a bit, and maybe the launcher icon problem can be mitigated this way: https://chris.orr.me.uk/android-apps-info-category/ So, the Activity would be containing something like this

Intent findASKIntent = new Intent("android.intent.action.MAIN");
    findASKIntent.setPackage("com.menny.android.anysoftkeyboard");
    findASKIntent.addCategory(CATEGORY_INFO);
List<ResolveInfo> listResolveInfo = getPackageManager().queryIntentActivities(findASKIntent, MATCH_ALL);
if (listResolveInfo.size() != 0) {
  // start the main ASK prefs screen
} else {
      createAlert("AnySoftKeyboard not installed!", "Install AnySoftKeyboard first, and then select the desired layout from AnySoftKeyboard's Settings->Keyboards menu.", true);
}

public void createAlert(String title, String message, Boolean button) {
    // http://androidideasblog.blogspot.com/2010/02/how-to-add-messagebox-in-android.html
    AlertDialog alertDialog;
    alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setTitle(title);
    alertDialog.setMessage(message);
    if ((button == true)) {
        alertDialog.setButton("Download Now",
        new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface arg0, int arg1) {
                Intent browserIntent = new Intent(
                    Intent.ACTION_VIEW,
                    Uri.parse("market://search?q=pname:com.menny.android.anysoftkeyboard"));
                startActivity(browserIntent);
            }
        });
    }
    alertDialog.show();
}

Is it possible to move most of that code to https://github.com/AnySoftKeyboard/AnySoftKeyboard-API/tree/master/api/src/main and only extend the Activity in the LanguagePack? That should make it easier to maintain.

We'd need to add a new

<intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.INFO"/>
</intent-filter>

to https://github.com/AnySoftKeyboard/AnySoftKeyboard/blob/master/app/src/main/AndroidManifest.xml (<activity android:name="com.anysoftkeyboard.ui.settings.MainSettingsActivity" ...></activity>) and the new languagepack.DummyActivity.

That way, after installing in the market (Play Store or F-Droid), the "Install" Button should change to "Start" as usual (not "Uninstall" like currently), sending the user to the alert and from there to the market search again, if ASK is not installed, and to the ASK preferences if it is installed.

I suspect this should be "good enough" for most users?

Two more options:

  • Add a
<intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.DEFAULT"/>
</intent-filter>

to the new Activity in each LanguagePack, thereby creating a launcher icon for people who try to find the keyboard from the launcher menu (are there any?). We should be able to remove the icon similar to https://github.com/AnySoftKeyboard/AnySoftKeyboard/blob/d703c5085294b1667f4a002593e34b6de2a28a36/app/src/main/java/com/menny/android/anysoftkeyboard/AnyApplication.java#L212 but only when called once?

  • For people who still don't find it, somehow add an own blank keyboard (fragment? service?), showing only the message and the install button, in each LanguagePack which will show up in the system's keyboard selection. But I have no idea about the implications of this...? Probably it is also not possible to "deactivate" that keyboard during runtime...?

friesenkiwi avatar Jul 27 '17 06:07 friesenkiwi

I just made a quick try with the queryIntentActivities/category.INFO variant and it seems to work quite nicely :-) If we move the Activity code into the API package, there only needs to be an "empty" Activity in each language pack and the changes everywhere (Main, API, LanguagePack master) should be small. I wouldn't go for the other two options.

friesenkiwi avatar Jul 27 '17 20:07 friesenkiwi

May I know what would be the steps to include a language pack into the main project? 😄 By that I mean including the language pack into the primary ASK apk.

coffeesam avatar Sep 28 '18 11:09 coffeesam