Search in sources :

Example 1 with CacheWordHandler

use of info.guardianproject.cacheword.CacheWordHandler in project storymaker by StoryMaker.

the class LockablePreferenceActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    int timeout = Integer.parseInt(settings.getString("pcachewordtimeout", BaseActivity.CACHEWORD_TIMEOUT));
    mCacheWordHandler = new CacheWordHandler(this, timeout);
}
Also used : SharedPreferences(android.content.SharedPreferences) CacheWordHandler(info.guardianproject.cacheword.CacheWordHandler)

Example 2 with CacheWordHandler

use of info.guardianproject.cacheword.CacheWordHandler in project storymaker by StoryMaker.

the class SMPanicResponderActivity method onCreate.

@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // need to check for pin before locking
    SharedPreferences sp = getSharedPreferences("appPrefs", MODE_PRIVATE);
    String cachewordStatus = sp.getString("cacheword_status", "default");
    if (cachewordStatus.equals(BaseActivity.CACHEWORD_SET)) {
        //Timber.d("panic - pin set, panic!");
        Intent intent = getIntent();
        if (intent != null && PANIC_TRIGGER_ACTION.equals(intent.getAction())) {
            SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
            int timeout = Integer.parseInt(settings.getString("pcachewordtimeout", BaseActivity.CACHEWORD_TIMEOUT));
            CacheWordHandler cacheWordHandler = new CacheWordHandler(this, timeout);
            cacheWordHandler.connectToService();
            cacheWordHandler.lock();
            cacheWordHandler.disconnectFromService();
            ExitActivity.exitAndRemoveFromRecentApps(this);
        }
    } else {
    //Timber.d("panic - no pin set, don't panic!");
    }
    if (Build.VERSION.SDK_INT >= 21) {
        finishAndRemoveTask();
    } else {
        finish();
    }
}
Also used : SharedPreferences(android.content.SharedPreferences) CacheWordHandler(info.guardianproject.cacheword.CacheWordHandler) Intent(android.content.Intent) SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint)

Example 3 with CacheWordHandler

use of info.guardianproject.cacheword.CacheWordHandler in project storymaker by StoryMaker.

the class BaseActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    int timeout = Integer.parseInt(settings.getString("pcachewordtimeout", CACHEWORD_TIMEOUT));
    mCacheWordHandler = new CacheWordHandler(this, timeout);
    if (!Eula.isAccepted(this)) {
        Intent firstStartIntent = new Intent(this, FirstStartActivity.class);
        firstStartIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(firstStartIntent);
    }
    setContentView(R.layout.activity_base);
    getActionBar().setHomeButtonEnabled(true);
}
Also used : SharedPreferences(android.content.SharedPreferences) CacheWordHandler(info.guardianproject.cacheword.CacheWordHandler) Intent(android.content.Intent)

Example 4 with CacheWordHandler

use of info.guardianproject.cacheword.CacheWordHandler in project storymaker by StoryMaker.

the class SceneEditorActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()) {
        case R.id.exportProjectFiles:
            exportProjectFiles();
            return true;
        case R.id.itemInfo:
            Intent intent = new Intent(this, StoryInfoActivity.class);
            intent.putExtra("pid", mProject.getId());
            startActivity(intent);
            return true;
        case R.id.purgePublishTables:
            // NEW/CACHEWORD
            SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
            int timeout = Integer.parseInt(settings.getString("pcachewordtimeout", CACHEWORD_TIMEOUT));
            mCacheWordHandler = new CacheWordHandler(getBaseContext(), this, timeout);
            mCacheWordHandler.connectToService();
            SQLiteDatabase db = new StoryMakerDB(mCacheWordHandler, getBaseContext()).getWritableDatabase();
            JobTable foo;
            (new PublishJobTable(db)).debugPurgeTable();
            (new JobTable(db)).debugPurgeTable();
            db.close();
            return true;
    }
    return super.onOptionsItemSelected(item);
}
Also used : PublishJobTable(org.storymaker.app.model.PublishJobTable) JobTable(org.storymaker.app.model.JobTable) PublishJobTable(org.storymaker.app.model.PublishJobTable) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) CacheWordHandler(info.guardianproject.cacheword.CacheWordHandler) Intent(android.content.Intent) StoryMakerDB(org.storymaker.app.db.StoryMakerDB)

Example 5 with CacheWordHandler

use of info.guardianproject.cacheword.CacheWordHandler in project storymaker by StoryMaker.

the class CacheWordActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_lock_screen);
    Intent intent = getIntent();
    setPin = intent.getBooleanExtra(BaseActivity.CACHEWORD_FIRST_LOCK, false);
    if (setPin) {
        Timber.d("got flag for cacheword pin initialization");
    } else {
        Timber.d("no flag for cacheword pin initialization");
    }
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    int timeout = Integer.parseInt(settings.getString("pcachewordtimeout", BaseActivity.CACHEWORD_TIMEOUT));
    mCacheWordHandler = new CacheWordHandler(this, timeout);
    mViewEnterPin = findViewById(R.id.llEnterPin);
    mViewCreatePin = findViewById(R.id.llCreatePin);
    mTextEnterPin = (EditText) findViewById(R.id.editEnterPin);
    mTextCreatePin = (EditText) findViewById(R.id.editCreatePin);
    mTextConfirmPin = (EditText) findViewById(R.id.editConfirmPin);
    ViewFlipper vf = (ViewFlipper) findViewById(R.id.viewFlipper);
    LinearLayout flipView1 = (LinearLayout) findViewById(R.id.flipView1);
    LinearLayout flipView2 = (LinearLayout) findViewById(R.id.flipView2);
    mSlider = new TwoViewSlider(vf, flipView1, flipView2, mTextCreatePin, mTextConfirmPin);
}
Also used : ViewFlipper(android.widget.ViewFlipper) SharedPreferences(android.content.SharedPreferences) CacheWordHandler(info.guardianproject.cacheword.CacheWordHandler) Intent(android.content.Intent) LinearLayout(android.widget.LinearLayout)

Aggregations

CacheWordHandler (info.guardianproject.cacheword.CacheWordHandler)7 SharedPreferences (android.content.SharedPreferences)5 Intent (android.content.Intent)4 SuppressLint (android.annotation.SuppressLint)1 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1 LinearLayout (android.widget.LinearLayout)1 ViewFlipper (android.widget.ViewFlipper)1 StoryMakerDB (org.storymaker.app.db.StoryMakerDB)1 JobTable (org.storymaker.app.model.JobTable)1 PublishJobTable (org.storymaker.app.model.PublishJobTable)1