colorpicker test
This commit is contained in:
parent
4e7407a033
commit
81fddd903d
@ -43,4 +43,12 @@ dependencies {
|
|||||||
testImplementation 'junit:junit:4.+'
|
testImplementation 'junit:junit:4.+'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||||
|
implementation 'android.support:support-v4:28.0.0'
|
||||||
|
implementation 'android.support:appcompat-v7:28.0.0'
|
||||||
|
implementation 'android.support:preference-v7:28.0.0'
|
||||||
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
|
implementation project(':colorpicker')
|
||||||
|
}
|
||||||
|
repositories {
|
||||||
|
maven { url "https://jitpack.io" }
|
||||||
}
|
}
|
@ -8,6 +8,7 @@ import android.graphics.Color;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.Preference;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.style.ForegroundColorSpan;
|
import android.text.style.ForegroundColorSpan;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -55,6 +56,12 @@ public class MainActivity extends AppCompatActivity implements AddButtonDialog.A
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
if (savedInstanceState == null) {
|
||||||
|
getSupportFragmentManager().beginTransaction()
|
||||||
|
.replace(android.R.id.content, new DemoPreferenceFragment())
|
||||||
|
.commit();
|
||||||
|
NonDeveloperMessage.maybeShow(this);
|
||||||
|
}
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
@ -99,7 +106,19 @@ public class MainActivity extends AppCompatActivity implements AddButtonDialog.A
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
static public class DemoPreferenceFragment extends PreferenceFragmentCompat {
|
||||||
|
@Override
|
||||||
|
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||||
|
addPreferencesFromResource(R.xml.preferences);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisplayPreferenceDialog(Preference preference) {
|
||||||
|
if (preference instanceof ColorPreference) {
|
||||||
|
((ColorPreference) preference).showDialog(this, 0);
|
||||||
|
} else super.onDisplayPreferenceDialog(preference);
|
||||||
|
}
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
// Inflate the menu; this adds items to the action bar if it is present.
|
// Inflate the menu; this adds items to the action bar if it is present.
|
||||||
|
19
app/src/main/java/de/jg_cody/Teraplex/ViewDemoActivity.java
Normal file
19
app/src/main/java/de/jg_cody/Teraplex/ViewDemoActivity.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package de.jg_cody.Teraplex;
|
||||||
|
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import de.jg_cody.Teraplex.ColorPickerView;
|
||||||
|
|
||||||
|
public class ViewDemoActivity extends Activity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.fragment_flur);
|
||||||
|
|
||||||
|
ColorPickerView picker = (ColorPickerView)findViewById(R.id.colorPicker);
|
||||||
|
picker.setColor(0xffff0000);
|
||||||
|
}
|
||||||
|
}
|
@ -58,7 +58,6 @@ public class FlurFragment extends Fragment implements View.OnClickListener {
|
|||||||
teamList.add("Australia");
|
teamList.add("Australia");
|
||||||
teamList.add("England");
|
teamList.add("England");
|
||||||
|
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@drawable/background"
|
android:background="@drawable/background"
|
||||||
@ -55,4 +57,13 @@
|
|||||||
android:textAllCaps="false"
|
android:textAllCaps="false"
|
||||||
android:textColor="@color/white"></Button>
|
android:textColor="@color/white"></Button>
|
||||||
|
|
||||||
|
<de.jg_cody.Teraplex.ColorPickerView
|
||||||
|
android:id="@+id/colorPicker"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:colorpicker_showAlpha="true"
|
||||||
|
app:colorpicker_showHex="true"
|
||||||
|
app:colorpicker_showPreview="true"
|
||||||
|
/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
54
app/src/main/res/preferences.xml
Normal file
54
app/src/main/res/preferences.xml
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<PreferenceScreen
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
|
<com.rarepebble.colorpicker.ColorPreference
|
||||||
|
android:key="simplePreference"
|
||||||
|
android:title="@string/pref_title"
|
||||||
|
android:defaultValue="#f00"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<com.rarepebble.colorpicker.ColorPreference
|
||||||
|
android:key="optionalColor"
|
||||||
|
android:title="@string/pref_optional_color"
|
||||||
|
app:colorpicker_noneSelectedSummaryText="@string/no_color_selected"
|
||||||
|
android:summary="@string/pref_optional_color_summary"
|
||||||
|
app:colorpicker_selectNoneButtonText="@string/no_color"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<com.rarepebble.colorpicker.ColorPreference
|
||||||
|
android:key="optionalColorWithDefault"
|
||||||
|
android:title="@string/pref_default_color"
|
||||||
|
android:summary="@string/pref_default_color_summary"
|
||||||
|
android:defaultValue="#f0f"
|
||||||
|
app:colorpicker_selectNoneButtonText="@string/default_color"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<com.rarepebble.colorpicker.ColorPreference
|
||||||
|
android:key="opaquePreference"
|
||||||
|
android:title="@string/pref_no_alpha"
|
||||||
|
android:summary="@string/pref_no_alpha_summary"
|
||||||
|
app:colorpicker_showAlpha="false"
|
||||||
|
android:defaultValue="#00f"
|
||||||
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
<com.rarepebble.colorpicker.ColorPreference
|
||||||
|
android:key="opaquePreferenceNoHex"
|
||||||
|
android:title="@string/pref_title_minimal"
|
||||||
|
android:summary="@string/pref_title_minimal_summary"
|
||||||
|
app:colorpicker_showAlpha="false"
|
||||||
|
app:colorpicker_showHex="false"
|
||||||
|
android:defaultValue="@color/example_color_resource"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<PreferenceScreen
|
||||||
|
android:title="@string/pref_show_view_usage_demo">
|
||||||
|
<intent
|
||||||
|
android:action="android.intent.action.VIEW"
|
||||||
|
android:targetClass="com.rarepebble.colorpickerdemo.ViewDemoActivity"
|
||||||
|
android:targetPackage="com.rarepebble.colorpickerdemo" />
|
||||||
|
</PreferenceScreen>
|
||||||
|
|
||||||
|
</PreferenceScreen>
|
Loading…
Reference in New Issue
Block a user