com.felkertech.settingsmanager.SettingsManager Java Examples

The following examples show how to use com.felkertech.settingsmanager.SettingsManager. 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 File: WidgetSelectionActivity.java    From CumulusTV with MIT License 6 votes vote down vote up
private void displayChannelPicker(final List<JsonChannel> jsonChannels, String[] channelNames,
          String label) {
    new AlertDialog.Builder(WidgetSelectionActivity.this)
            .setTitle(label)
            .setItems(channelNames, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    JsonChannel jsonChannel = jsonChannels.get(i);
                    SettingsManager settingsManager =
                            new SettingsManager(WidgetSelectionActivity.this);
                    settingsManager.setString(SETTINGS_MANAGER_WIDGET_URL + mAppWidgetId,
                            jsonChannel.getMediaUrl());
                    completeConfiguration();
                }
            })
            .show();
}
 
Example #2
Source File: ChannelDatabase.java    From CumulusTV with MIT License 6 votes vote down vote up
protected ChannelDatabase(final Context context) {
    mSettingsManager = new SettingsManager(context);
    try {
        DriveSettingsManager sp = new DriveSettingsManager(context);
        String spData = sp.getString(KEY, getDefaultJsonString());
        if (spData.isEmpty()) {
            spData = getDefaultJsonString();
        }
        mJsonObject = new JSONObject(spData);
        if (!mJsonObject.has(KEY_MODIFIED)) {
            mJsonObject.put(KEY_MODIFIED, 0L);
            save();
        }
        resetPossibleGenres(); // This will try to use the newest API data
    } catch (final JSONException e) {
        throw new MalformedChannelDataException(e.getMessage());
    }
}
 
Example #3
Source File: OnboardingActivity.java    From Launch-On-Boot with MIT License 5 votes vote down vote up
/**
 * Called when the activity is first created.
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.onboarding);
    // Update the shared preferences
    new SettingsManager(this).setBoolean(SettingsManagerConstants.ONBOARDING, true);

}
 
Example #4
Source File: MainActivity.java    From Launch-On-Boot with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mSettingsManager = new SettingsManager(this);
    if (!mSettingsManager.getBoolean(ONBOARDING)) {
        startActivity(new Intent(this, OnboardingActivity.class));
    }
}
 
Example #5
Source File: TifSetupFragment.java    From CumulusTV with MIT License 5 votes vote down vote up
@Override
public void onScanStarted() {
    EpgSyncJobService.cancelAllSyncRequests(getActivity());
    CumulusJobService.requestImmediateSync1(getActivity(), mInputId, CumulusJobService.DEFAULT_IMMEDIATE_EPG_DURATION_MILLIS,
            new ComponentName(getActivity(), CumulusJobService.class));

    new SettingsManager(getActivity())
            .setString(EpgSyncJobService.BUNDLE_KEY_INPUT_ID, mInputId);

    setButtonText(getString(R.string.in_progress));
}
 
Example #6
Source File: ActivityUtils.java    From CumulusTV with MIT License 5 votes vote down vote up
public static void openIntroIfNeeded(Activity activity) {
    SettingsManager sm = new SettingsManager(activity);
    if(sm.getInt(R.string.sm_last_version) < LAST_GOOD_BUILD) {
        activity.startActivity(new Intent(activity, Intro.class));
        activity.finish();
    }
}
 
Example #7
Source File: CloudStorageProvider.java    From CumulusTV with MIT License 5 votes vote down vote up
public boolean autoConnect(Activity activity) {
    if(isDriveEnabled(activity)) {
        if (DEBUG) {
            Log.d(TAG, "Drive is enabled, automatically connect");
            Log.d(TAG, ">" + new SettingsManager(activity).getString(R.string.sm_google_drive_id).length());
            Log.d(TAG, new SettingsManager(activity).getString(R.string.sm_google_drive_id) + "<");
        }
        connect(activity);
        return true;
    }
    if (DEBUG) {
        Log.d(TAG, "Drive is not enabled, don't connect yet.");
    }
    return false;
}
 
Example #8
Source File: MockChannelDatabase.java    From CumulusTV with MIT License 5 votes vote down vote up
protected MockChannelDatabase(final Context context) throws JSONException {
    super(context);
    SettingsManager settingsManager = new SettingsManager(context);
    String jsonString = settingsManager.getString(KEY, getDefaultJsonString());
    if (jsonString.isEmpty()) {
        jsonString = getDefaultJsonString();
    }
    mJsonObject = new JSONObject(jsonString);
}
 
Example #9
Source File: ChannelDatabaseUnitTest.java    From CumulusTV with MIT License 5 votes vote down vote up
/**
 * Deletes data from the {@link SettingsManager}.
 */
@Before
public void clearDatabase() {
    MockChannelDatabase.reset();
    SettingsManager settingsManager = new SettingsManager(RuntimeEnvironment.application);
    settingsManager.setString(MockChannelDatabase.KEY, "");
}
 
Example #10
Source File: SampleTvInputProvider.java    From ChannelSurfer with MIT License 4 votes vote down vote up
public boolean shouldShowToasts() {
    return new SettingsManager(this).getBoolean(R.string.sm_debug);
}
 
Example #11
Source File: WidgetSelectionActivity.java    From CumulusTV with MIT License 4 votes vote down vote up
public static JsonChannel getWidgetChannel(Context context, int appWidgetId) {
    ChannelDatabase channelDatabase = ChannelDatabase.getInstance(context);
    String mediaUrl = new SettingsManager(context)
            .getString(SETTINGS_MANAGER_WIDGET_URL + appWidgetId);
    return channelDatabase.findChannelByMediaUrl(mediaUrl);
}
 
Example #12
Source File: CloudStorageProvider.java    From CumulusTV with MIT License 4 votes vote down vote up
public boolean isDriveEnabled(Activity activity) {
    String gdriveId = new SettingsManager(activity).getString(R.string.sm_google_drive_id);
    Log.d(TAG, R.string.sm_google_drive_id + " " + gdriveId);
    return !gdriveId.isEmpty() && gdriveId.length() > 0;
}