2019-06-17 09:49:09 +02:00
|
|
|
package lu.circl.mispbump.activities;
|
|
|
|
|
2019-07-24 12:06:52 +02:00
|
|
|
|
2019-10-10 13:51:24 +02:00
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.net.Uri;
|
2019-06-17 09:49:09 +02:00
|
|
|
import android.os.Bundle;
|
2019-10-13 18:24:46 +02:00
|
|
|
import android.view.MenuItem;
|
2019-07-23 23:04:07 +02:00
|
|
|
|
2019-10-13 18:24:46 +02:00
|
|
|
import androidx.annotation.NonNull;
|
2019-07-24 13:40:08 +02:00
|
|
|
import androidx.appcompat.app.ActionBar;
|
2019-07-23 23:04:07 +02:00
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
import androidx.appcompat.widget.Toolbar;
|
2019-07-24 20:32:13 +02:00
|
|
|
import androidx.preference.Preference;
|
2019-10-10 13:51:24 +02:00
|
|
|
import androidx.preference.PreferenceCategory;
|
2019-07-24 13:40:08 +02:00
|
|
|
import androidx.preference.PreferenceFragmentCompat;
|
2019-10-10 13:51:24 +02:00
|
|
|
import androidx.preference.PreferenceScreen;
|
2019-06-17 09:49:09 +02:00
|
|
|
|
|
|
|
import lu.circl.mispbump.R;
|
|
|
|
|
2019-07-24 12:06:52 +02:00
|
|
|
|
2019-06-17 09:49:09 +02:00
|
|
|
public class PreferenceActivity extends AppCompatActivity {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
setContentView(R.layout.activity_preference);
|
2019-07-24 20:32:13 +02:00
|
|
|
|
2019-07-23 23:04:07 +02:00
|
|
|
Toolbar myToolbar = findViewById(R.id.toolbar);
|
|
|
|
setSupportActionBar(myToolbar);
|
|
|
|
|
2019-07-24 13:40:08 +02:00
|
|
|
ActionBar ab = getSupportActionBar();
|
|
|
|
assert ab != null;
|
|
|
|
ab.setDisplayHomeAsUpEnabled(true);
|
|
|
|
|
2019-10-10 13:51:24 +02:00
|
|
|
getSupportFragmentManager()
|
|
|
|
.beginTransaction()
|
|
|
|
.add(R.id.fragmentContainer, new PreferencesFragment(PreferenceActivity.this))
|
|
|
|
.commit();
|
2019-06-17 09:49:09 +02:00
|
|
|
}
|
2019-07-24 13:40:08 +02:00
|
|
|
|
2019-10-13 18:24:46 +02:00
|
|
|
@Override
|
|
|
|
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
|
|
|
if (item.getItemId() == android.R.id.home) {
|
|
|
|
onBackPressed();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-24 13:40:08 +02:00
|
|
|
public static class PreferencesFragment extends PreferenceFragmentCompat {
|
2019-07-24 20:32:13 +02:00
|
|
|
|
2019-10-10 13:51:24 +02:00
|
|
|
private Context context;
|
|
|
|
|
|
|
|
PreferencesFragment(Context context) {
|
|
|
|
this.context = context;
|
|
|
|
}
|
2019-07-24 20:32:13 +02:00
|
|
|
|
2019-07-24 13:40:08 +02:00
|
|
|
@Override
|
|
|
|
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
2019-10-10 13:51:24 +02:00
|
|
|
PreferenceScreen preferenceScreen = getPreferenceManager().createPreferenceScreen(context);
|
|
|
|
setPreferenceScreen(preferenceScreen);
|
|
|
|
|
|
|
|
// General
|
|
|
|
|
2019-10-12 19:02:56 +02:00
|
|
|
// PreferenceCategory generalCategory = new PreferenceCategory(context);
|
|
|
|
// generalCategory.setTitle("General");
|
|
|
|
// getPreferenceScreen().addPreference(generalCategory);
|
|
|
|
//
|
|
|
|
// SwitchPreference fetchOnlyLocalSyncs = new SwitchPreference(context);
|
|
|
|
// fetchOnlyLocalSyncs.setTitle("Display local syncs only");
|
|
|
|
// fetchOnlyLocalSyncs.setSummaryOn("Only those syncs that were made with MISPbump are displayed.");
|
|
|
|
// fetchOnlyLocalSyncs.setSummaryOff("Existing syncs from your MISP instance are fetched (experimental)");
|
|
|
|
// fetchOnlyLocalSyncs.setChecked(preferenceManager.getShowLocalSyncsOnly());
|
|
|
|
// fetchOnlyLocalSyncs.setOnPreferenceChangeListener((preference, newValue) -> {
|
|
|
|
// preferenceManager.setShowLocalSyncsOnly((boolean) newValue);
|
|
|
|
// return true;
|
|
|
|
// });
|
|
|
|
//
|
|
|
|
// generalCategory.addPreference(fetchOnlyLocalSyncs);
|
2019-10-10 13:51:24 +02:00
|
|
|
|
|
|
|
// App Information
|
|
|
|
|
|
|
|
PreferenceCategory appInfoCategory = new PreferenceCategory(context);
|
|
|
|
appInfoCategory.setTitle("App Information");
|
|
|
|
getPreferenceScreen().addPreference(appInfoCategory);
|
|
|
|
|
|
|
|
Preference githubPreference = new Preference(context);
|
|
|
|
githubPreference.setIcon(context.getDrawable(R.drawable.ic_github));
|
|
|
|
githubPreference.setTitle("Github");
|
|
|
|
githubPreference.setSummary("Visit the Github project");
|
|
|
|
Intent viewOnGithub = new Intent(Intent.ACTION_VIEW);
|
|
|
|
viewOnGithub.setData(Uri.parse("https://github.com/MISP/misp-bump"));
|
|
|
|
githubPreference.setIntent(viewOnGithub);
|
|
|
|
|
|
|
|
Preference versionPreference = new Preference(context);
|
|
|
|
versionPreference.setIcon(context.getDrawable(R.drawable.ic_info_outline_dark));
|
|
|
|
versionPreference.setTitle("Version");
|
|
|
|
versionPreference.setSummary("1.0");
|
|
|
|
|
|
|
|
appInfoCategory.addPreference(githubPreference);
|
|
|
|
appInfoCategory.addPreference(versionPreference);
|
2019-07-24 13:40:08 +02:00
|
|
|
}
|
|
|
|
}
|
2019-06-17 09:49:09 +02:00
|
|
|
}
|