add preference screen (WIP)

pull/1/head
Felix Prahl-Kamps 2019-07-23 23:04:07 +02:00
parent 42dcd9b58d
commit 95710ae4e8
11 changed files with 87 additions and 51 deletions

View File

@ -38,7 +38,7 @@
</value> </value>
</option> </option>
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

View File

@ -29,6 +29,7 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0' implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.preference:preference:1.1.0-rc01'
// retrofit // retrofit
implementation 'com.squareup.retrofit2:retrofit:2.6.0' implementation 'com.squareup.retrofit2:retrofit:2.6.0'
@ -36,15 +37,12 @@ dependencies {
implementation 'com.squareup.okhttp3:logging-interceptor:3.11.0' implementation 'com.squareup.okhttp3:logging-interceptor:3.11.0'
// barcode reading // barcode reading
implementation 'com.google.android.gms:play-services-vision:17.0.2' implementation 'com.google.android.gms:play-services-vision:18.0.0'
// barcode generation // barcode generation
implementation 'com.journeyapps:zxing-android-embedded:3.2.0@aar' implementation 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
implementation 'com.google.zxing:core:3.4.0' implementation 'com.google.zxing:core:3.4.0'
// external
implementation 'me.saket:inboxrecyclerview:1.0.0-rc1'
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test:runner:1.2.0'

View File

@ -45,6 +45,7 @@
android:parentActivityName=".activities.HomeActivity" /> android:parentActivityName=".activities.HomeActivity" />
<activity <activity
android:name=".activities.PreferenceActivity" android:name=".activities.PreferenceActivity"
android:label="@string/settings"
android:parentActivityName=".activities.HomeActivity" /> android:parentActivityName=".activities.HomeActivity" />
<activity <activity
android:name=".activities.ProfileActivity" android:name=".activities.ProfileActivity"

View File

@ -26,8 +26,6 @@ import lu.circl.mispbump.models.UploadInformation;
public class HomeActivity extends AppCompatActivity { public class HomeActivity extends AppCompatActivity {
public static String EXTRA_UPLOAD_INFO = "uploadInformation";
private List<UploadInformation> uploadInformationList; private List<UploadInformation> uploadInformationList;
private PreferenceManager preferenceManager; private PreferenceManager preferenceManager;
private RecyclerView recyclerView; private RecyclerView recyclerView;
@ -53,10 +51,10 @@ public class HomeActivity extends AppCompatActivity {
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
// if (item.getItemId() == R.id.menu_settings) { if (item.getItemId() == R.id.menu_settings) {
// startActivity(new Intent(HomeActivity.this, PreferenceActivity.class)); startActivity(new Intent(HomeActivity.this, PreferenceActivity.class));
// return true; return true;
// } }
if (item.getItemId() == R.id.menu_profile) { if (item.getItemId() == R.id.menu_profile) {
startActivity(new Intent(HomeActivity.this, ProfileActivity.class)); startActivity(new Intent(HomeActivity.this, ProfileActivity.class));

View File

@ -3,7 +3,6 @@ package lu.circl.mispbump.activities;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
@ -210,6 +209,6 @@ public class LoginActivity extends AppCompatActivity {
* @return true or false * @return true or false
*/ */
private boolean isValidAutomationKey(String automationKey) { private boolean isValidAutomationKey(String automationKey) {
return !TextUtils.isEmpty(automationKey); return !automationKey.equals("");
} }
} }

View File

@ -1,35 +1,31 @@
package lu.circl.mispbump.activities; package lu.circl.mispbump.activities;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle; import android.os.Bundle;
import android.view.View;
import android.widget.Button; import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import lu.circl.mispbump.R; import lu.circl.mispbump.R;
import lu.circl.mispbump.auxiliary.PreferenceManager; import lu.circl.mispbump.fragments.PreferencesFragment;
public class PreferenceActivity extends AppCompatActivity { public class PreferenceActivity extends AppCompatActivity {
private PreferenceManager preferenceManager;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_preference); setContentView(R.layout.activity_preference);
preferenceManager = PreferenceManager.getInstance(PreferenceActivity.this);
initializeViews(); initializeViews();
} }
private void initializeViews() { private void initializeViews() {
Button deleteSyncs = findViewById(R.id.deleteSyncs); Toolbar myToolbar = findViewById(R.id.toolbar);
deleteSyncs.setOnClickListener(new View.OnClickListener() { setSupportActionBar(myToolbar);
@Override
public void onClick(View v) { FragmentManager fragmentManager = getSupportFragmentManager();
preferenceManager.clearUploadInformation(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
} fragmentTransaction.add(R.id.fragmentContainer, new PreferencesFragment(), PreferencesFragment.class.getSimpleName());
}); fragmentTransaction.commit();
} }
} }

View File

@ -0,0 +1,14 @@
package lu.circl.mispbump.fragments;
import android.os.Bundle;
import androidx.preference.PreferenceFragmentCompat;
import lu.circl.mispbump.R;
public class PreferencesFragment extends PreferenceFragmentCompat {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.app_preferences, rootKey);
}
}

View File

@ -1,21 +1,26 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".activities.PreferenceActivity"> android:layout_width="match_parent">
<com.google.android.material.button.MaterialButton <com.google.android.material.appbar.AppBarLayout
android:id="@+id/deleteSyncs" android:layout_width="match_parent"
android:layout_width="0dp" android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:text="Delete Syncs"/>
</androidx.constraintlayout.widget.ConstraintLayout> <androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="@style/ToolbarTheme"
app:popupTheme="@style/PopupTheme" />
</com.google.android.material.appbar.AppBarLayout>
<FrameLayout
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
android:id="@+id/fragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -8,9 +8,9 @@
android:title="Profile" android:title="Profile"
app:showAsAction="ifRoom"/> app:showAsAction="ifRoom"/>
<!--<item--> <item
<!--android:id="@+id/menu_settings"--> android:id="@+id/menu_settings"
<!--android:icon="@drawable/ic_settings"--> android:icon="@drawable/ic_settings"
<!--android:title="Settings"--> android:title="Settings"
<!--app:showAsAction="never"/>--> app:showAsAction="never"/>
</menu> </menu>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="language_name_array">
<item>English</item>
<item>German</item>
</string-array>
<string-array name="language_value_array">
<item>en</item>
<item>de</item>
</string-array>
</resources>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="General">
<ListPreference
app:key="language"
app:title="Language"
app:entries="@array/language_name_array"
app:entryValues="@array/language_value_array"
app:icon="@drawable/ic_language"/>
</PreferenceCategory>
</PreferenceScreen>