Skip to content

Commit

Permalink
Merge pull request #7 from gt945/master
Browse files Browse the repository at this point in the history
Add default keyboard layout option
  • Loading branch information
whs authored Jun 24, 2017
2 parents 31a9e65 + 8ccd00f commit 76927db
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 119 deletions.
25 changes: 21 additions & 4 deletions app/src/main/java/th/in/whs/k2ausbkbd/KeepassActionReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import keepass2android.pluginsdk.KeepassDefs;
import keepass2android.pluginsdk.PluginAccessException;
import keepass2android.pluginsdk.PluginActionBroadcastReceiver;
import keepass2android.pluginsdk.Strings;
import th.in.whs.k2ausbkbd.hid.Keyboard;
import th.in.whs.k2ausbkbd.layout.KeyboardLayoutFactory;
import th.in.whs.k2ausbkbd.layout.Layout;
import java.io.IOException;


public class KeepassActionReceiver extends PluginActionBroadcastReceiver {
@Override
Expand Down Expand Up @@ -63,10 +71,19 @@ protected void actionSelected(ActionSelectedAction actionSelected) {
type.append(actionSelected.getEntryFields().get(fieldKey));
}

Intent intent = new Intent(ctx, LayoutPromptActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("type", type.toString());
ctx.startActivity(intent);
if (type.length() > 0) {
try {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(ctx);
String layout = preferences.getString("default_keyboard", "QWERTY");
Layout layoutInstance = KeyboardLayoutFactory.getLayout(layout);
Keyboard.getInstance().type(type.toString(), layoutInstance);
} catch (IOException | InstantiationException | IllegalAccessException e) {
Toast.makeText(null, R.string.error_send, Toast.LENGTH_LONG).show();
e.printStackTrace();
} catch (UnsupportedOperationException e) {
Toast.makeText(null, R.string.error_kernel, Toast.LENGTH_LONG).show();
}
}
}

}
47 changes: 0 additions & 47 deletions app/src/main/java/th/in/whs/k2ausbkbd/LayoutPromptActivity.java

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

6 changes: 6 additions & 0 deletions app/src/main/res/xml/pref_general.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,11 @@
android:key="hide_from_launcher"
android:title="@string/hide_launcher"
android:summary="@string/hide_launcher_restore"/>
<ListPreference
android:defaultValue="QWERTY"
android:entries="@array/layout_list"
android:entryValues="@array/layout_list"
android:key="default_keyboard"
android:title="Default Keyboard Layout" />

</PreferenceScreen>

0 comments on commit 76927db

Please sign in to comment.