Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added code to make all the screens secure #579

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ public int compareTo(Object o) {
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
// Use setFlagSecure(Context) to disable screenshots on the Activities.
//Keyboard.setFlagSecure(this);
addPreferencesFromResource(R.xml.language_prefs);
// Get the settings preferences
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
Expand Down
14 changes: 14 additions & 0 deletions java/src/org/pocketworkstation/pckeyboard/Keyboard.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
import android.util.Xml;
import android.util.DisplayMetrics;

import android.app.Activity;
import android.view.WindowManager;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
Expand Down Expand Up @@ -1309,6 +1312,17 @@ static float getDimensionOrFraction(TypedArray a, int index, int base, float def
return defValue;
}

/**
* Method to set FLAG_SECURE inside activities
*
* @param activity
* @see <a href="https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_SECURE">FLAG_SECURE</a>
*/
public static void setFlagSecure(Activity activity) {
activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE,
WindowManager.LayoutParams.FLAG_SECURE);
}

@Override
public String toString() {
return "Keyboard(" + mLayoutColumns + "x" + mLayoutRows +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public class LatinIMEDebugSettings extends PreferenceActivity
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
// Use setFlagSecure(Context) to disable screenshots on the Activities.
//Keyboard.setFlagSecure(this);
addPreferencesFromResource(R.xml.prefs_for_debug);
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
prefs.registerOnSharedPreferenceChangeListener(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class LatinIMESettings extends PreferenceActivity
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
Keyboard.setFlagSecure(this);
addPreferencesFromResource(R.xml.prefs);
mQuickFixes = (CheckBoxPreference) findPreference(QUICK_FIXES_KEY);
mVoicePreference = (ListPreference) findPreference(VOICE_SETTINGS_KEY);
Expand Down
10 changes: 6 additions & 4 deletions java/src/org/pocketworkstation/pckeyboard/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public class Main extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Use setFlagSecure(Context) to disable screenshots on the Activities.
//Keyboard.setFlagSecure(this);
String html = getString(R.string.main_body);
html += "<p><i>Version: " + getString(R.string.auto_version) + "</i></p>";
Spanned content = Html.fromHtml(html);
Expand All @@ -62,7 +64,7 @@ public void onClick(View v) {
mgr.showInputMethodPicker();
}
});

final Activity that = this;

final Button setup4 = (Button) findViewById(R.id.main_setup_btn_input_lang);
Expand All @@ -77,16 +79,16 @@ public void onClick(View v) {
public void onClick(View v) {
Intent it = new Intent(Intent.ACTION_VIEW, Uri.parse(MARKET_URI));
try {
startActivity(it);
startActivity(it);
} catch (ActivityNotFoundException e) {
Toast.makeText(getApplicationContext(),
getResources().getString(
R.string.no_market_warning), Toast.LENGTH_LONG)
R.string.no_market_warning), Toast.LENGTH_LONG)
.show();
}
}
});
// PluginManager.getPluginDictionaries(getApplicationContext()); // why?
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public class PrefScreenActions extends PreferenceActivity
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
// Use setFlagSecure(Context) to disable screenshots on the Activities.
//Keyboard.setFlagSecure(this);
addPreferencesFromResource(R.xml.prefs_actions);
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
prefs.registerOnSharedPreferenceChangeListener(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public class PrefScreenFeedback extends PreferenceActivity
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
// Use setFlagSecure(Context) to disable screenshots on the Activities.
//Keyboard.setFlagSecure(this);
addPreferencesFromResource(R.xml.prefs_feedback);
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
prefs.registerOnSharedPreferenceChangeListener(this);
Expand Down
2 changes: 2 additions & 0 deletions java/src/org/pocketworkstation/pckeyboard/PrefScreenView.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class PrefScreenView extends PreferenceActivity
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
// Use setFlagSecure(Context) to disable screenshots on the Activities.
//Keyboard.setFlagSecure(this);
addPreferencesFromResource(R.xml.prefs_view);
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
prefs.registerOnSharedPreferenceChangeListener(this);
Expand Down