mirror of
https://github.com/yuliskov/LeanKeyboard.git
synced 2026-05-03 05:12:36 -04:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb13108a11 | ||
|
|
43ef8324bf |
@@ -8,8 +8,8 @@ android {
|
||||
applicationId "org.liskovsoft.leankeykeyboard.pro"
|
||||
minSdkVersion project.properties.minSdkVersion
|
||||
targetSdkVersion project.properties.targetSdkVersion
|
||||
versionCode 78
|
||||
versionName "4.3.28"
|
||||
versionCode 80
|
||||
versionName "4.3.30"
|
||||
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
|
||||
|
||||
@@ -5,9 +5,14 @@
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
||||
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES"/>
|
||||
<application android:banner="@drawable/banner_app" android:label="@string/ime_name" android:icon="@drawable/ic_launcher" tools:targetApi="21">
|
||||
<activity android:launchMode="singleTop" android:name="com.liskovsoft.other.SettingsActivity">
|
||||
<activity android:launchMode="singleTop" android:name="com.liskovsoft.other.GenericLaunchActivity">
|
||||
<meta-data android:name="package" android:value="com.android.settings"/>
|
||||
<meta-data android:name="class" android:value="com.android.settings.Settings$InputMethodAndLanguageSettingsActivity"/>
|
||||
<meta-data android:name="class" android:value="com.android.settings.Settings$LanguageAndInputSettingsActivity"/>
|
||||
<!-- "Languages & input" on old api -->
|
||||
<meta-data android:name="package_alt" android:value="com.android.settings"/>
|
||||
<meta-data android:name="class_alt" android:value="com.android.settings.Settings$InputMethodAndLanguageSettingsActivity"/>
|
||||
<!-- Last try (if above not found) -->
|
||||
<meta-data android:name="intent" android:value="android.settings.INPUT_METHOD_SETTINGS"/>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
package com.liskovsoft.other;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.widget.Toast;
|
||||
import android.os.Bundle;
|
||||
import android.content.ComponentName;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.Intent;
|
||||
import android.app.Activity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GenericLaunchActivity extends Activity
|
||||
{
|
||||
private static final String META_PACKAGE_NAME = "package";
|
||||
private static final String META_CLASS_NAME = "class";
|
||||
private static final String META_PACKAGE_NAME_ALT = "package_alt";
|
||||
private static final String META_CLASS_NAME_ALT = "class_alt";
|
||||
private static final String META_INTENT_NAME = "intent";
|
||||
private List<Intent> mIntents = new ArrayList<>();
|
||||
|
||||
protected void onCreate(final Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
launchApp();
|
||||
}
|
||||
|
||||
@SuppressLint("WrongConstant")
|
||||
private void addCommonIntentFlags(final Intent intent) {
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
}
|
||||
|
||||
@SuppressLint("WrongConstant")
|
||||
private ActivityInfo getCurrentActivityInfo() {
|
||||
try {
|
||||
return getPackageManager().getActivityInfo(getComponentName(), PackageManager.GET_META_DATA | PackageManager.GET_ACTIVITIES);
|
||||
}
|
||||
catch (NameNotFoundException ex) {
|
||||
ex.printStackTrace();
|
||||
makeLongToast(ex.getLocalizedMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void launchApp() {
|
||||
makeIntentList();
|
||||
startIntents();
|
||||
finish();
|
||||
}
|
||||
|
||||
private void startIntents() {
|
||||
for (Intent intent : mIntents) {
|
||||
boolean result = startIntent(intent);
|
||||
if (result) { // run until first successful attempt
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void makeIntentList() {
|
||||
final ActivityInfo activityInfo = getCurrentActivityInfo();
|
||||
if (activityInfo == null) {
|
||||
return;
|
||||
}
|
||||
final Bundle metaData = activityInfo.metaData;
|
||||
|
||||
String metaPackageName = metaData.getString(META_PACKAGE_NAME);
|
||||
String metaClassName = metaData.getString(META_CLASS_NAME);
|
||||
mIntents.add(createIntent(metaPackageName, metaClassName));
|
||||
|
||||
String metaPackageNameAlt = metaData.getString(META_PACKAGE_NAME_ALT);
|
||||
String metaClassNameAlt = metaData.getString(META_CLASS_NAME_ALT);
|
||||
mIntents.add(createIntent(metaPackageNameAlt, metaClassNameAlt));
|
||||
|
||||
String metaIntentName = metaData.getString(META_INTENT_NAME);
|
||||
mIntents.add(createIntent(metaIntentName));
|
||||
}
|
||||
|
||||
private Intent createIntent(String intentName) {
|
||||
if (intentName == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final Intent intent = new Intent();
|
||||
intent.setAction(intentName);
|
||||
addCommonIntentFlags(intent);
|
||||
return intent;
|
||||
}
|
||||
|
||||
private Intent createIntent(String packageName, String className) {
|
||||
if (packageName == null || className == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final Intent intent = new Intent();
|
||||
intent.setComponent(new ComponentName(packageName, className));
|
||||
addCommonIntentFlags(intent);
|
||||
return intent;
|
||||
}
|
||||
|
||||
private void makeLongToast(final String s) {
|
||||
makeLongToast(s, 10);
|
||||
}
|
||||
|
||||
private void makeLongToast(final String s, int nums) {
|
||||
int n;
|
||||
for (n = nums / 2, nums = 0; nums < n; ++nums) {
|
||||
Toast.makeText(this, s, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean startIntent(final Intent intent) {
|
||||
if (intent == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
startActivity(intent);
|
||||
}
|
||||
catch (ActivityNotFoundException ex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package com.liskovsoft.other;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.widget.Toast;
|
||||
import android.os.Bundle;
|
||||
import android.content.ComponentName;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.Intent;
|
||||
import android.app.Activity;
|
||||
|
||||
public class SettingsActivity extends Activity
|
||||
{
|
||||
@SuppressLint("WrongConstant")
|
||||
private void addIntentFlags(final Intent intent) {
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
}
|
||||
|
||||
@SuppressLint("WrongConstant")
|
||||
private ActivityInfo getCurrentActivityInfo() {
|
||||
try {
|
||||
return getPackageManager().getActivityInfo(getComponentName(), PackageManager.GET_META_DATA | PackageManager.GET_ACTIVITIES);
|
||||
}
|
||||
catch (NameNotFoundException ex) {
|
||||
ex.printStackTrace();
|
||||
makeLongToast(ex.getLocalizedMessage(), 10);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void launchApp() {
|
||||
final Intent intent = makeIntent(getCurrentActivityInfo());
|
||||
addIntentFlags(intent);
|
||||
startIntent(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
private Intent makeIntent(final ActivityInfo activityInfo) {
|
||||
final Bundle metaData = activityInfo.metaData;
|
||||
final Intent intent = new Intent();
|
||||
if (metaData.getString("intent") != null) {
|
||||
intent.setAction(metaData.getString("intent"));
|
||||
return intent;
|
||||
}
|
||||
intent.setComponent(new ComponentName(metaData.getString("package"), metaData.getString("class")));
|
||||
return intent;
|
||||
}
|
||||
|
||||
private void makeLongToast(final String s, int nums) {
|
||||
int n;
|
||||
for (n = nums / 2, nums = 0; nums < n; ++nums) {
|
||||
Toast.makeText(this, s, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
private void startIntent(final Intent intent) {
|
||||
try {
|
||||
startActivity(intent);
|
||||
}
|
||||
catch (ActivityNotFoundException ex) {
|
||||
ex.printStackTrace();
|
||||
makeLongToast(ex.getLocalizedMessage(), 10);
|
||||
}
|
||||
}
|
||||
|
||||
protected void onCreate(final Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
launchApp();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user