Java Code Examples for android.app.backup.BackupManager

The following examples show how to use android.app.backup.BackupManager. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: openboard   Source File: SubScreenFragment.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mSharedPreferenceChangeListener = new OnSharedPreferenceChangeListener() {
        @Override
        public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) {
            final SubScreenFragment fragment = SubScreenFragment.this;
            final Context context = fragment.getActivity();
            if (context == null || fragment.getPreferenceScreen() == null) {
                final String tag = fragment.getClass().getSimpleName();
                // TODO: Introduce a static function to register this class and ensure that
                // onCreate must be called before "onSharedPreferenceChanged" is called.
                Log.w(tag, "onSharedPreferenceChanged called before activity starts.");
                return;
            }
            new BackupManager(context).dataChanged();
            fragment.onSharedPreferenceChanged(prefs, key);
        }
    };
    getSharedPreferences().registerOnSharedPreferenceChangeListener(
            mSharedPreferenceChangeListener);
}
 
Example 2
Source Project: Android-Keyboard   Source File: SubScreenFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mSharedPreferenceChangeListener = new OnSharedPreferenceChangeListener() {
        @Override
        public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) {
            final SubScreenFragment fragment = SubScreenFragment.this;
            final Context context = fragment.getActivity();
            if (context == null || fragment.getPreferenceScreen() == null) {
                final String tag = fragment.getClass().getSimpleName();
                // TODO: Introduce a static function to register this class and ensure that
                // onCreate must be called before "onSharedPreferenceChanged" is called.
                Log.w(tag, "onSharedPreferenceChanged called before activity starts.");
                return;
            }
            new BackupManager(context).dataChanged();
            fragment.onSharedPreferenceChanged(prefs, key);
        }
    };
    getSharedPreferences().registerOnSharedPreferenceChangeListener(
            mSharedPreferenceChangeListener);
}
 
Example 3
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mSharedPreferenceChangeListener = new OnSharedPreferenceChangeListener() {
        @Override
        public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) {
            final SubScreenFragment fragment = SubScreenFragment.this;
            final Context context = fragment.getActivity();
            if (context == null || fragment.getPreferenceScreen() == null) {
                final String tag = fragment.getClass().getSimpleName();
                // TODO: Introduce a static function to register this class and ensure that
                // onCreate must be called before "onSharedPreferenceChanged" is called.
                Log.w(tag, "onSharedPreferenceChanged called before activity starts.");
                return;
            }
            new BackupManager(context).dataChanged();
            fragment.onSharedPreferenceChanged(prefs, key);
        }
    };
    getSharedPreferences().registerOnSharedPreferenceChangeListener(
            mSharedPreferenceChangeListener);
}
 
Example 4
Source Project: simple-keyboard   Source File: SubScreenFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mSharedPreferenceChangeListener = new OnSharedPreferenceChangeListener() {
        @Override
        public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) {
            final SubScreenFragment fragment = SubScreenFragment.this;
            final Context context = fragment.getActivity();
            if (context == null || fragment.getPreferenceScreen() == null) {
                final String tag = fragment.getClass().getSimpleName();
                // TODO: Introduce a static function to register this class and ensure that
                // onCreate must be called before "onSharedPreferenceChanged" is called.
                Log.w(tag, "onSharedPreferenceChanged called before activity starts.");
                return;
            }
            new BackupManager(context).dataChanged();
            fragment.onSharedPreferenceChanged(prefs, key);
        }
    };
    getSharedPreferences().registerOnSharedPreferenceChangeListener(
            mSharedPreferenceChangeListener);
}
 
Example 5
Source Project: andOTP   Source File: DatabaseHelper.java    License: MIT License 6 votes vote down vote up
public static boolean saveDatabase(Context context, ArrayList<Entry> entries, SecretKey encryptionKey) {
    if (encryptionKey == null) {
        Toast.makeText(context, R.string.toast_encryption_key_empty, Toast.LENGTH_LONG).show();
        return false;
    }

    String jsonString = entriesToString(entries);

    try {
        synchronized (DatabaseHelper.DatabaseFileLock) {
            byte[] data = EncryptionHelper.encrypt(encryptionKey, jsonString.getBytes());

            FileHelper.writeBytesToFile(new File(context.getFilesDir() + "/" + Constants.FILENAME_DATABASE), data);
        }
    } catch (Exception error) {
        error.printStackTrace();
        return false;
    }

    BackupManager backupManager = new BackupManager(context);
    backupManager.dataChanged();

    return true;
}
 
Example 6
Source Project: AOSP-Kayboard-7.1.2   Source File: SubScreenFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mSharedPreferenceChangeListener = new OnSharedPreferenceChangeListener() {
        @Override
        public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) {
            final SubScreenFragment fragment = SubScreenFragment.this;
            final Context context = fragment.getActivity();
            if (context == null || fragment.getPreferenceScreen() == null) {
                final String tag = fragment.getClass().getSimpleName();
                // TODO: Introduce a static function to register this class and ensure that
                // onCreate must be called before "onSharedPreferenceChanged" is called.
                Log.w(tag, "onSharedPreferenceChanged called before activity starts.");
                return;
            }
            new BackupManager(context).dataChanged();
            fragment.onSharedPreferenceChanged(prefs, key);
        }
    };
    getSharedPreferences().registerOnSharedPreferenceChangeListener(
            mSharedPreferenceChangeListener);
}
 
Example 7
public static String getUserID(Context context) {
    if (uniqueID == null) {
        SharedPreferences sharedPrefs = context.getSharedPreferences(SimpleBackupAgent.PREFS, Context.MODE_PRIVATE);
        uniqueID = sharedPrefs.getString(PREF_UNIQUE_ID, null);
        if (uniqueID == null) {
            uniqueID = UUID.randomUUID().toString();
            SharedPreferences.Editor editor = sharedPrefs.edit();
            editor.putString(PREF_UNIQUE_ID, uniqueID);
            editor.commit();

            //backup the changes
            BackupManager mBackupManager = new BackupManager(context);
            mBackupManager.dataChanged();
        }
    }

    return uniqueID;
}
 
Example 8
Source Project: Noyze   Source File: ConfigurationActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    LOGI(TAG, "onSharedPreferenceChanged(" + key + ')');
    Context context = getApplicationContext();
    if (null != context) {
        (new BackupManager(context)).dataChanged();
    }

    if (Constants.PREF_VOLUME_PANEL.equals(key)) {
        // TRACK: what theme is being used.
        String panel = sharedPreferences.getString(key, StatusBarVolumePanel.TAG);
        VolumeAccessibilityService.VolumePanelChangeEvent event =
                new VolumeAccessibilityService.VolumePanelChangeEvent(panel, Utils.supportsMediaPlayback(panel));
        onVolumePanelChangeEvent(event);
    } else if (Constants.PREF_REPORTING.equals(key)) {
        // TRACK: when the user opts out of being tracked.
    }
}
 
Example 9
Source Project: chromadoze   Source File: ChromaDoze.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onPause() {
    super.onPause();

    // If the equalizer is silent, stop the service.
    // This makes it harder to leave running accidentally.
    if (mServiceActive && mUiState.getPhonon().isSilent()) {
        NoiseService.stopNow(getApplication(), R.string.stop_reason_silent);
    }

    SharedPreferences.Editor pref = getSharedPreferences(PREF_NAME, MODE_PRIVATE).edit();
    pref.clear();
    mUiState.saveState(pref);
    pref.commit();
    new BackupManager(this).dataChanged();

    // Stop receiving progress events.
    NoiseService.removePercentListener(this);
    mUiState.removeLockListener(this);
}
 
Example 10
Source Project: Noyze   Source File: ConfigurationActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    LOGI(TAG, "onSharedPreferenceChanged(" + key + ')');
    Context context = getApplicationContext();
    if (null != context) {
        (new BackupManager(context)).dataChanged();
    }

    if (Constants.PREF_VOLUME_PANEL.equals(key)) {
        // TRACK: what theme is being used.
        String panel = sharedPreferences.getString(key, StatusBarVolumePanel.TAG);
        VolumeAccessibilityService.VolumePanelChangeEvent event =
                new VolumeAccessibilityService.VolumePanelChangeEvent(panel, Utils.supportsMediaPlayback(panel));
        onVolumePanelChangeEvent(event);
    } else if (Constants.PREF_REPORTING.equals(key)) {
        // TRACK: when the user opts out of being tracked.
    }
}
 
Example 11
Source Project: Indic-Keyboard   Source File: SubScreenFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mSharedPreferenceChangeListener = new OnSharedPreferenceChangeListener() {
        @Override
        public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) {
            final SubScreenFragment fragment = SubScreenFragment.this;
            final Context context = fragment.getActivity();
            if (context == null || fragment.getPreferenceScreen() == null) {
                final String tag = fragment.getClass().getSimpleName();
                // TODO: Introduce a static function to register this class and ensure that
                // onCreate must be called before "onSharedPreferenceChanged" is called.
                Log.w(tag, "onSharedPreferenceChanged called before activity starts.");
                return;
            }
            new BackupManager(context).dataChanged();
            fragment.onSharedPreferenceChanged(prefs, key);
        }
    };
    getSharedPreferences().registerOnSharedPreferenceChangeListener(
            mSharedPreferenceChangeListener);
}
 
Example 12
Source Project: android_9.0.0_r45   Source File: LockSettingsService.java    License: Apache License 2.0 5 votes vote down vote up
private void setStringUnchecked(String key, int userId, String value) {
    Preconditions.checkArgument(userId != USER_FRP, "cannot store lock settings for FRP user");

    mStorage.writeKeyValue(key, value, userId);
    if (ArrayUtils.contains(SETTINGS_TO_BACKUP, key)) {
        BackupManager.dataChanged("com.android.providers.settings");
    }
}
 
Example 13
Source Project: ShadowsocksRR   Source File: Shadowsocks.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onDestroy() {
    super.onDestroy();
    isDestroyed = true;
    mServiceBoundContext.detachService();
    new BackupManager(this).dataChanged();
    handler.removeCallbacksAndMessages(null);
}
 
Example 14
Source Project: Maying   Source File: Shadowsocks.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onDestroy() {
    super.onDestroy();
    isDestroyed = true;
    mServiceBoundContext.detachService();
    new BackupManager(this).dataChanged();
    handler.removeCallbacksAndMessages(null);
}
 
Example 15
Source Project: mobikul-standalone-pos   Source File: MyBackupAgent.java    License: MIT License 5 votes vote down vote up
@Override
    public void onCreate() {
//        SharedPreferencesBackupHelper helper = new SharedPreferencesBackupHelper(this, PREFS, USER_PREFS);
//        addHelper(PREFS_BACKUP_KEY, helper);
        FileBackupHelper fileBackupHelper = new FileBackupHelper(this, dBFile);
        addHelper("dbFile", fileBackupHelper);
//        FileBackupHelper fileBackupHelper1 = new FileBackupHelper(this, dBImageFile);
//        addHelper("dbFile", fileBackupHelper1);
        new BackupManager(getApplicationContext()).dataChanged();
    }
 
Example 16
Source Project: andOTP   Source File: SettingsActivity.java    License: MIT License 5 votes vote down vote up
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
    BackupManager backupManager = new BackupManager(this);
    backupManager.dataChanged();

    if (key.equals(getString(R.string.settings_key_theme)) ||
            key.equals(getString(R.string.settings_key_locale)) ||
            key.equals(getString(R.string.settings_key_special_features)) ||
            key.equals(getString(R.string.settings_key_backup_location))) {
        recreate();
    } else if(key.equals(getString(R.string.settings_key_encryption))) {
        if (settings.getEncryption() != EncryptionType.PASSWORD) {
            if (settings.getAndroidBackupServiceEnabled()) {
                UIHelper.showGenericDialog(this,
                    R.string.settings_dialog_title_android_sync,
                    R.string.settings_dialog_msg_android_sync_disabled_encryption
                );
            }

            settings.setAndroidBackupServiceEnabled(false);
            if (fragment.useAndroidSync != null) {
                fragment.useAndroidSync.setEnabled(false);
                fragment.useAndroidSync.setChecked(false);
            }
        } else {
            if (fragment.useAndroidSync != null)
                fragment.useAndroidSync.setEnabled(true);
        }
    }

    fragment.updateAutoBackup();
}
 
Example 17
Source Project: science-journal   Source File: SimpleBackupAgent.java    License: Apache License 2.0 5 votes vote down vote up
/** Schedule backups each time the preferences are modified. */
public static SharedPreferences.OnSharedPreferenceChangeListener
    registerOnSharedPreferencesChangeListener(Context applicationContext) {
  SharedPreferences.OnSharedPreferenceChangeListener listener =
      (sharedPreferences, s) ->
          BackupManager.dataChanged("com.google.android.apps.forscience.whistlepunk");
  PreferenceManager.getDefaultSharedPreferences(applicationContext)
      .registerOnSharedPreferenceChangeListener(listener);
  return listener;
}
 
Example 18
Source Project: octoandroid   Source File: DbHelper.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Inject
public DbHelper(PrinterDbEntityDao printerDbEntityDao, PrefHelper prefHelper,
                BackupManager backupManager) {
    mPrinterDbEntityDao = printerDbEntityDao;
    mPrefHelper = prefHelper;
    mBackupManager = backupManager;
}
 
Example 19
Source Project: AndroidChromium   Source File: ChromeBackupWatcher.java    License: Apache License 2.0 5 votes vote down vote up
private ChromeBackupWatcher() {
    Context context = ContextUtils.getApplicationContext();
    if (context == null) return;

    mBackupManager = new BackupManager(context);
    // Watch the Java preferences that are backed up.
    SharedPreferences sharedPrefs = ContextUtils.getAppSharedPreferences();
    // If we have never done a backup do one immediately.
    if (!sharedPrefs.getBoolean(FIRST_BACKUP_DONE, false)) {
        mBackupManager.dataChanged();
        sharedPrefs.edit().putBoolean(FIRST_BACKUP_DONE, true).apply();
    }
    sharedPrefs.registerOnSharedPreferenceChangeListener(
            new SharedPreferences.OnSharedPreferenceChangeListener() {

                @Override
                public void onSharedPreferenceChanged(
                        SharedPreferences sharedPreferences, String key) {
                    // Update the backup if the user id or any of the backed up Android
                    // preferences change.
                    if (key.equals(ChromeSigninController.SIGNED_IN_ACCOUNT_KEY)) {
                        onBackupPrefsChanged();
                        return;
                    }
                    for (String pref : ChromeBackupAgent.BACKUP_ANDROID_BOOL_PREFS) {
                        if (key.equals(pref)) {
                            onBackupPrefsChanged();
                            return;
                        }
                    }
                }

            });
}
 
Example 20
Source Project: Study_Android_Demo   Source File: SettingsProvider.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreate() {
    mBackupManager = new BackupManager(getContext());
    mUserManager = UserManager.get(getContext());

    setAppOps(AppOpsManager.OP_NONE, AppOpsManager.OP_WRITE_SETTINGS);
    establishDbTracking(UserHandle.USER_OWNER);

    IntentFilter userFilter = new IntentFilter();
    userFilter.addAction(Intent.ACTION_USER_REMOVED);
    userFilter.addAction(Intent.ACTION_USER_ADDED);
    getContext().registerReceiver(new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            final int userHandle = intent.getIntExtra(Intent.EXTRA_USER_HANDLE,
                    UserHandle.USER_OWNER);
            if (intent.getAction().equals(Intent.ACTION_USER_REMOVED)) {
                onUserRemoved(userHandle);
            } else if (intent.getAction().equals(Intent.ACTION_USER_ADDED)) {
                onProfilesChanged();
            }
        }
    }, userFilter);

    onProfilesChanged();

    return true;
}
 
Example 21
Source Project: Study_Android_Demo   Source File: SettingsProvider.java    License: Apache License 2.0 5 votes vote down vote up
public SettingsRegistry() {
    mHandler = new MyHandler(getContext().getMainLooper());
    mGenerationRegistry = new GenerationRegistry(mLock);
    mBackupManager = new BackupManager(getContext());
    migrateAllLegacySettingsIfNeeded();
    syncSsaidTableOnStart();
}
 
Example 22
Source Project: hackerskeyboard   Source File: LatinIMESettings.java    License: Apache License 2.0 5 votes vote down vote up
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
    (new BackupManager(this)).dataChanged();
    // If turning on voice input, show dialog
    if (key.equals(VOICE_SETTINGS_KEY) && !mVoiceOn) {
        if (!prefs.getString(VOICE_SETTINGS_KEY, mVoiceModeOff)
                .equals(mVoiceModeOff)) {
            showVoiceConfirmation();
        }
    }
    mVoiceOn = !(prefs.getString(VOICE_SETTINGS_KEY, mVoiceModeOff).equals(mVoiceModeOff));
    updateVoiceModeSummary();
    updateSummaries();
}
 
Example 23
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    identityProvider = DeviceIdentityProvider.getInstance(this);

    // force backup for new device immediately
    if (identityProvider.isNewDevice()) {
        BackupManager backupManager = new BackupManager(this);
        backupManager.dataChanged();
    }
    
    initView();
}
 
Example 24
@Override
protected void onStop() {
    // allow backup authorized devices only
    if (identityProvider.isAuthorizedDevice()) {
        BackupManager backupManager = new BackupManager(this);
        backupManager.dataChanged();
    }

    super.onStop();
}
 
Example 25
Source Project: 365browser   Source File: ChromeBackupWatcher.java    License: Apache License 2.0 5 votes vote down vote up
private ChromeBackupWatcher() {
    Context context = ContextUtils.getApplicationContext();
    if (context == null) return;

    mBackupManager = new BackupManager(context);
    // Watch the Java preferences that are backed up.
    SharedPreferences sharedPrefs = ContextUtils.getAppSharedPreferences();
    // If we have never done a backup do one immediately.
    if (!sharedPrefs.getBoolean(FIRST_BACKUP_DONE, false)) {
        mBackupManager.dataChanged();
        sharedPrefs.edit().putBoolean(FIRST_BACKUP_DONE, true).apply();
    }
    sharedPrefs.registerOnSharedPreferenceChangeListener(
            new SharedPreferences.OnSharedPreferenceChangeListener() {

                @Override
                public void onSharedPreferenceChanged(
                        SharedPreferences sharedPreferences, String key) {
                    // Update the backup if the user id or any of the backed up Android
                    // preferences change.
                    if (key.equals(ChromeSigninController.SIGNED_IN_ACCOUNT_KEY)) {
                        onBackupPrefsChanged();
                        return;
                    }
                    for (String pref : ChromeBackupAgent.BACKUP_ANDROID_BOOL_PREFS) {
                        if (key.equals(pref)) {
                            onBackupPrefsChanged();
                            return;
                        }
                    }
                }

            });
}
 
Example 26
@TargetApi(Build.VERSION_CODES.FROYO)
public WorkTimeTrackerBackupManager(final Context context) {
	prefKeyBackupEnabled = context.getText(R.string.keyBackupEnabled) + "";
	backupManager = new BackupManager(context);
	timestampPrefs = context.getSharedPreferences("timestampPrefs", Context.MODE_PRIVATE);
	defaultPrefs = PreferenceManager.getDefaultSharedPreferences(context);
	enabled = defaultPrefs.getBoolean(prefKeyBackupEnabled, true);
}
 
Example 27
Source Project: coursera-android   Source File: BrowserProvider.java    License: MIT License 5 votes vote down vote up
@Override
public boolean onCreate() {
    final Context context = getContext();
    boolean xlargeScreenSize = (context.getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK)
            == Configuration.SCREENLAYOUT_SIZE_XLARGE;
    boolean isPortrait = (context.getResources().getConfiguration().orientation
            == Configuration.ORIENTATION_PORTRAIT);


    if (xlargeScreenSize && isPortrait) {
        mMaxSuggestionLongSize = MAX_SUGGEST_LONG_LARGE;
        mMaxSuggestionShortSize = MAX_SUGGEST_SHORT_LARGE;
    } else {
        mMaxSuggestionLongSize = MAX_SUGGEST_LONG_SMALL;
        mMaxSuggestionShortSize = MAX_SUGGEST_SHORT_SMALL;
    }
    mOpenHelper = new DatabaseHelper(context);
    mBackupManager = new BackupManager(context);
    // we added "picasa web album" into default bookmarks for version 19.
    // To avoid erasing the bookmark table, we added it explicitly for
    // version 18 and 19 as in the other cases, we will erase the table.
    if (DATABASE_VERSION == 18 || DATABASE_VERSION == 19) {
        SharedPreferences p = PreferenceManager
                .getDefaultSharedPreferences(context);
        boolean fix = p.getBoolean("fix_picasa", true);
        if (fix) {
            fixPicasaBookmark();
            Editor ed = p.edit();
            ed.putBoolean("fix_picasa", false);
            ed.apply();
        }
    }
    mSettings = BrowserSettings.getInstance();
    return true;
}
 
Example 28
Source Project: ghwatch   Source File: StartActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  PreferencesUtils.setAppNightMode(this);

  // set default preferences first time app is started
  PreferenceManager.setDefaultValues(this, R.xml.preferences, false);

  // start notifications during first app run after installation
  SharedPreferences wmbPreference = PreferenceManager.getDefaultSharedPreferences(this);
  boolean isFirstRun = wmbPreference.getBoolean("FIRSTRUN", true);
  if (isFirstRun) {
    ActivityTracker.sendEvent(this, ActivityTracker.CAT_UI, "FIRST_RUN", "FIRST_RUN", 0L);
    AlarmBroadcastReceiver.startServerPoolingIfEnabled(this);
    SharedPreferences.Editor editor = wmbPreference.edit();
    editor.putBoolean("FIRSTRUN", false);
    editor.putLong("FIRSTRUNTIMESTAMP", System.currentTimeMillis());
    editor.commit();
    (new BackupManager(this)).dataChanged();
  }

  if (AuthenticationManager.getInstance().loadCurrentUser(this) != null) {
    showMainPage(false);
  } else {
    setContentView(R.layout.activity_start);
    Button button = (Button) findViewById(R.id.button_login_github);
    button.setOnClickListener(new OnClickListener() {

      @Override
      public void onClick(View v) {
        showLoginDialog();
      }
    });
  }

}
 
Example 29
Source Project: ghwatch   Source File: SettingsActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  mBackupManager = new BackupManager(this);
  // Display the fragment as the main content.
  sf = new SettingsFragment();
  getFragmentManager().beginTransaction().replace(android.R.id.content, sf).commit();

  android.support.v7.app.ActionBar actionBar = getSupportActionBar();
  actionBar.setDisplayHomeAsUpEnabled(true);
  authenticationManager = AuthenticationManager.getInstance();
}
 
Example 30
/**
 * Check if this dialog should be shown now.
 * 
 * @param activity
 * @return true if dialog should be shown now.
 */
public static boolean isAutoShowScheduled(MainActivity activity) {

  if (PreferencesUtils.readDonationTimestamp(activity) != null)
    return false;

  long lastShowTimestamp = PreferencesUtils.getLong(activity, SupportAppDevelopmentDialogFragment.PREF_LAST_SUPPORT_SHOW_TIMESTAMP, 0);
  if (lastShowTimestamp == 0) {
    storeTimestampOfLastShow(activity, System.currentTimeMillis() - (AUTO_SHOW_PERIOD - AUTO_SHOW_FIRST));
    (new BackupManager(activity)).dataChanged();
  } else {
    return lastShowTimestamp <= (System.currentTimeMillis() - AUTO_SHOW_PERIOD);
  }
  return false;
}