यहाँ मैं क्या सोचता है काम कर सकते हैं:
आप निम्न मान की आवश्यकता होगी:
लाल, हरा, नीला, अल्फा और कंट्रास्ट (आर, जी, बी, एक, ग)
एक प्राथमिकता में
स्टोर उन्हें स्लाइडर्स उपयोग करने के बाद:
private SharedPreferences pref;
//In onCreate..
this.pref = getSharedPreferences("pref", 0);
//Method to save the values in Preferences
private void save()
{
SharedPreferences.Editor localEditor = this.pref.edit();
localEditor.putInt("a", this.a);
localEditor.putInt("r", this.r);
localEditor.putInt("g", this.g);
localEditor.putInt("b", this.b);
localEditor.putInt("c", this.c);
localEditor.commit();
}
परिभाषित एक परत Clas एस जो दृश्य को बढ़ाता है और कैनवास पर लागू मूल्यों को आकर्षित करने के लिए उपयोग किया जाता है।
import android.view.View;
import android.graphics.Canvas;
import android.content.Context;
public class Layer extends View
{
private int a;
private int b;
private int g;
private int r;
public Layer(Context context){
super(context)
}
protected void onDraw(Canvas canvas){
super.onDraw(canvas);
canvas.drawARGB(this.a, this.r, this.g, this.b);
}
public void setColor(int a, int r, int g, int b){
this.a = a;
this.r = r;
this.g = g;
this.b = b;
invalidate();
}
}
अगला एक सेवा है जो इन मूल्यों में परिवर्तन को संभालने और उन्हें खिड़कियों को लागू करने के लिए माना जाता है लिखें।
public class ScreenAdjustService extends Service
{
//Handle everything here
}
// मानों Prefs निजी स्थिर परत दृश्य में जमा हो जाती है लागू करने के लिए विचारों घोषित; ... सार्वजनिक स्थैतिक int r; सार्वजनिक स्थिर int बी; सार्वजनिक स्थिर int जी; सार्वजनिक स्थैतिक int ए; सार्वजनिक स्थिर int सी;
onCreate विधि में,
प्राप्त मूल्यों पहले वरीयताओं में जमा हो जाती, पुनः प्राप्त मूल्यों की स्थापना के लिए
SharedPreferences localSharedPreferences = getSharedPreferences("pref", 0);
a = localSharedPreferences.getInt("a", 0);
r = localSharedPreferences.getInt("r", 0);
g = localSharedPreferences.getInt("g", 0);
b = localSharedPreferences.getInt("b", 0);
c = localSharedPreferences.getInt("c", 0);
सेट दृश्य,
view = new Layer(this);
redView = new Layer(this);
...
खिड़की करने के लिए इन विचारों जोड़े
//Pass the necessary values for localLayoutParams
WindowManager.LayoutParams localLayoutParams = new WindowManager.LayoutParams(...);
WindowManager localWindowManager = (WindowManager)getSystemService("window");
localWindowManager.addView(view, localLayoutParams);
localWindowManager.addView(redView, localLayoutParams);
localWindowManager.addView(greenView, localLayoutParams);
लिखें पुन: प्रयोज्य तरीकों
public static void setAlpha(int alpha){
//Handle all conditions
view.setColor(alpha, 0, 0, 0);
}
public static void setContrast(int contrast){
//Handle all conditions
view.setColor(c, 100, 100, 100);
}
public static void setRGB(int r, int g, int b){
//Handle all conditions
redView.setColor(r, 255, 0, 0);
greenView.setColor(g, 0, 255, 0);
blueView.setColor(b, 0, 0, 255);
}
कॉल सेवा वर्ग का उपयोग कर
ScreenAdjustService.setRGB(MyActivity.this.r, MyActivity.this.g, MyActivity.this.b);
ScreenAdjustService.setAlpha(MyActivity.this.a);
ScreenAdjustService.setContrast(MyActivity.this.c);
मत भूलना
<service android:name=".ScreenAdjustService " />
मैं हो सकता है प्रकट xml फ़ाइल में आपकी सेवा घोषित करने के लिए इन तरीकों जहां आवश्यक मैंने एक या दो चीज़ों को याद किया है क्योंकि मैंने इसे फ्लाई पर किया था, लेकिन मुझे लगता है कि इसे करना चाहिए।
भी, आपको हर समय शीर्ष पर होने के लिए झंडे जोड़ने की जरूरत है। – tomwesolowski
तो, इस दृष्टिकोण में यह ओवरलैड गतिविधि ओवरलैप्ड गतिविधि के लिए स्पर्श घटनाओं को कैसे पार कर रही है? – Paras