AppCompatPreferenceimport android.content.res.Configuration;import android.os.Bundle; import android.preference.PreferenceActivity; import android.support.annotation.LayoutRes; import android.support.annotation.Nullable; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatDelegate; import android.support.v7.widget.Toolbar; import android.view.MenuInflater; import android.view.View; import android.view.ViewGroup; /** * A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls * to be used with AppCompat. */public abstract class AppCompatPreference extends PreferenceActivity { private AppCompatDelegate mDelegate; @Override protected void onCreate(Bundle savedInstanceState) { getDelegate().installViewFactory(); getDelegate().onCreate(savedInstanceState); super.onCreate(savedInstanceState); } @Override protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); getDelegate().onPostCreate(savedInstanceState); } public ActionBar getSupportActionBar() { return getDelegate().getSupportActionBar(); } public void setSupportActionBar(@Nullable Toolbar toolbar) { getDelegate().setSupportActionBar(toolbar); } @Override public MenuInflater getMenuInflater() { return getDelegate().getMenuInflater(); } @Override public void setContentView(@LayoutRes int layoutResID) { getDelegate().setContentView(layoutResID); } @Override public void setContentView(View view) { getDelegate().setContentView(view); } @Override public void setContentView(View view, ViewGroup.LayoutParams params) { getDelegate().setContentView(view, params); } @Override public void addContentView(View view, ViewGroup.LayoutParams params) { getDelegate().addContentView(view, params); } @Override protected void onPostResume() { super.onPostResume(); getDelegate().onPostResume(); } @Override protected void onTitleChanged(CharSequence title, int color) { super.onTitleChanged(title, color); getDelegate().setTitle(title); } @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); getDelegate().onConfigurationChanged(newConfig); } @Override protected void onStop() { super.onStop(); getDelegate().onStop(); } @Override protected void onDestroy() { super.onDestroy(); getDelegate().onDestroy(); } public void invalidateOptionsMenu() { getDelegate().invalidateOptionsMenu(); } private AppCompatDelegate getDelegate() { if (mDelegate == null) { mDelegate = AppCompatDelegate.create(this, null); } return mDelegate; } }
AppCompatPreferenceActivitypackage blooger.blooger.com.myapplication; import android.content.res.Configuration; import android.os.Bundle; import android.preference.PreferenceActivity; import android.support.annotation.LayoutRes; import android.support.annotation.Nullable; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatDelegate; import android.support.v7.widget.Toolbar; import android.view.MenuInflater; import android.view.View; import android.view.ViewGroup; /** * A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls * to be used with AppCompat. */public abstract class AppCompatPreferenceActivity extends PreferenceActivity { private AppCompatDelegate mDelegate; @Override protected void onCreate(Bundle savedInstanceState) { getDelegate().installViewFactory(); getDelegate().onCreate(savedInstanceState); super.onCreate(savedInstanceState); } @Override protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); getDelegate().onPostCreate(savedInstanceState); } public ActionBar getSupportActionBar() { return getDelegate().getSupportActionBar(); } public void setSupportActionBar(@Nullable Toolbar toolbar) { getDelegate().setSupportActionBar(toolbar); } @Override public MenuInflater getMenuInflater() { return getDelegate().getMenuInflater(); } @Override public void setContentView(@LayoutRes int layoutResID) { getDelegate().setContentView(layoutResID); } @Override public void setContentView(View view) { getDelegate().setContentView(view); } @Override public void setContentView(View view, ViewGroup.LayoutParams params) { getDelegate().setContentView(view, params); } @Override public void addContentView(View view, ViewGroup.LayoutParams params) { getDelegate().addContentView(view, params); } @Override protected void onPostResume() { super.onPostResume(); getDelegate().onPostResume(); } @Override protected void onTitleChanged(CharSequence title, int color) { super.onTitleChanged(title, color); getDelegate().setTitle(title); } @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); getDelegate().onConfigurationChanged(newConfig); } @Override protected void onStop() { super.onStop(); getDelegate().onStop(); } @Override protected void onDestroy() { super.onDestroy(); getDelegate().onDestroy(); } public void invalidateOptionsMenu() { getDelegate().invalidateOptionsMenu(); } private AppCompatDelegate getDelegate() { if (mDelegate == null) { mDelegate = AppCompatDelegate.create(this, null); } return mDelegate; } }
MainActivitypackage blooger.blooger.com.myapplication; import android.content.Intent; import android.os.Bundle; //import android.support.design.widget.FloatingActionButton;//import android.support.design.widget.Snackbar;import android.support.design.widget.*; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.View; import android.view.Menu; import android.view.MenuItem; import android.content.Intent; import android.net.Uri; import android.os.Build; import android.support.v4.content.FileProvider; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import java.io.File; import android.app.ProgressDialog; import android.content.Intent; import android.net.Uri; import android.os.AsyncTask; import android.os.Environment; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; public class MainActivity extends AppCompatActivity { ProgressDialog bar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.action_settings) { // launch settings activity startActivity(new Intent(MainActivity.this, SettingsActivity.class)); return true; } return super.onOptionsItemSelected(item); } public void onklc(View view) { Intent intent = new Intent(Intent.ACTION_DELETE); intent.setData(Uri.parse("package:com.belal.belal")); startActivity(intent); } public void button2(View view) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse("file://https://play.google.com/store/apps/details?id=com.ss.android.ugc.boom" .toString()), "application/vnd.android.package-archive"); startActivity(intent); } }
SettingsActivitypackage blooger.blooger.com.myapplication; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.media.Ringtone; import android.media.RingtoneManager; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.preference.EditTextPreference; import android.preference.ListPreference; import android.preference.Preference; import android.preference.PreferenceFragment; import android.preference.PreferenceManager; import android.preference.RingtonePreference; import android.text.TextUtils; import android.view.MenuItem; public class SettingsActivity extends AppCompatPreferenceActivity { private static final String TAG = SettingsActivity.class.getSimpleName(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // load settings fragment getFragmentManager().beginTransaction().replace(android.R.id.content, new MainPreferenceFragment()).commit(); } public static class MainPreferenceFragment extends PreferenceFragment { @Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.pref_main); // gallery EditText change listener bindPreferenceSummaryToValue(findPreference(getString(R.string.key_gallery_name))); // notification preference change listener bindPreferenceSummaryToValue(findPreference(getString(R.string.key_notifications_new_message_ringtone))); // feedback preference click listener Preference myPref = findPreference(getString(R.string.key_send_feedback)); myPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { sendFeedback(getActivity()); return true; } }); } } @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { onBackPressed(); } return super.onOptionsItemSelected(item); } private static void bindPreferenceSummaryToValue(Preference preference) { preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener); sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, PreferenceManager .getDefaultSharedPreferences(preference.getContext()) .getString(preference.getKey(), "")); } /** * A preference value change listener that updates the preference's summary * to reflect its new value. */ private static Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { String stringValue = newValue.toString(); if (preference instanceof ListPreference) { // For list preferences, look up the correct display value in // the preference's 'entries' list. ListPreference listPreference = (ListPreference) preference; int index = listPreference.findIndexOfValue(stringValue); // Set the summary to reflect the new value. preference.setSummary( index >= 0 ? listPreference.getEntries()[index] : null); } else if (preference instanceof RingtonePreference) { // For ringtone preferences, look up the correct display value // using RingtoneManager. if (TextUtils.isEmpty(stringValue)) { // Empty values correspond to 'silent' (no ringtone). preference.setSummary(R.string.pref_ringtone_silent); } else { Ringtone ringtone = RingtoneManager.getRingtone( preference.getContext(), Uri.parse(stringValue)); if (ringtone == null) { // Clear the summary if there was a lookup error. preference.setSummary(R.string.summary_choose_ringtone); } else { // Set the summary to reflect the new ringtone display // name. String name = ringtone.getTitle(preference.getContext()); preference.setSummary(name); } } } else if (preference instanceof EditTextPreference) { if (preference.getKey().equals("key_gallery_name")) { // update the changed gallery name to summary filed preference.setSummary(stringValue); } } else { preference.setSummary(stringValue); } return true; } }; /** * Email client intent to send support mail * Appends the necessary device information to email body * useful when providing support */ public static void sendFeedback(Context context) { String body = null; try { body = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; body = "\n\n-----------------------------\nلدي استفسار وهو: " + Build.VERSION.RELEASE + "\n App Version: " + body + "\n Device Brand: " + Build.BRAND + "\n Device Model: " + Build.MODEL + "\n Device Manufacturer: " + Build.MANUFACTURER; } catch (PackageManager.NameNotFoundException e) { } Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("message/rfc822"); intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"savantmomani@gmail.com"}); intent.putExtra(Intent.EXTRA_SUBJECT, "Query from android app"); intent.putExtra(Intent.EXTRA_TEXT, body); context.startActivity(Intent.createChooser(intent, context.getString(R.string.choose_email_client))); } }menu
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android"> <item xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/action_settings" android:icon="@android:drawable/ic_menu_preferences" android:orderInCategory="100" android:title="@string/action_settings" app:showAsAction="ifRoom" /> </menu>xml
<?xml version="1.0" encoding="utf-8"?><PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceCategory android:title="General"> <EditTextPreference android:defaultValue="@string/default_gallery_storage" android:key="@string/key_gallery_name" android:summary="@string/default_gallery_storage" android:title="@string/title_gallery_storage" /> <CheckBoxPreference android:defaultValue="true" android:key="@string/key_upload_over_wifi" android:summary="@string/summary_upload_over_wifi" android:title="@string/title_auto_upload" /> <ListPreference android:defaultValue="3" android:dialogTitle="@string/title_upload_quality" android:entries="@array/pref_upload_quality_entries" android:entryValues="@array/pref_upload_quality_values" android:key="@string/key_upload_quality" android:summary="@string/summary_upload_video_quality" android:title="@string/title_upload_quality" /> </PreferenceCategory> <PreferenceCategory android:title="@string/pref_title_notifications"> <SwitchPreference android:defaultValue="true" android:key="@string/notifications_new_message" android:title="@string/title_new_notification_sound" /> <RingtonePreference android:defaultValue="content://settings/system/notification_sound" android:dependency="notifications_new_message" android:key="@string/key_notifications_new_message_ringtone" android:ringtoneType="notification" android:summary="@string/summary_choose_ringtone" android:title="@string/pref_title_ringtone" /> <SwitchPreference android:defaultValue="true" android:key="@string/key_vibrate" android:summary="@string/summary_vibrate" android:title="@string/title_vibrate" /> </PreferenceCategory> <PreferenceCategory android:title="@string/pref_header_about"> <Preference android:selectable="false" android:summary="@string/summary_about" /> <Preference android:summary="@string/app_version" android:title="@string/title_version" /> <Preference android:key="@string/key_send_feedback" android:summary="@string/summary_support" android:title="@string/title_send_feedback" /> <!-- preference opens url in browser --> <Preference android:summary="@string/summary_faq" android:title="@string/title_faq"> <intent android:action="android.intent.action.VIEW" android:data="@string/url_faq" /> </Preference> <Preference android:title="@string/privacy_policy"> <intent android:action="android.intent.action.VIEW" android:data="@string/url_privacy" /> </Preference> <Preference android:title="@string/title_terms"> <intent android:action="android.intent.action.VIEW" android:data="@string/url_terms" /> </Preference> </PreferenceCategory> </PreferenceScreen>string
<resources> <string name="app_name">My Application</string> <!-- Strings related to Settings --> <!-- Example General settings --> <string name="pref_header_general">عام</string> <string name="pref_title_social_recommendations">Enable social recommendations</string> <string name="pref_description_social_recommendations">Recommendations for people to contact based on your message history </string> <string name="pref_title_display_name">اسم العرض</string> <string name="pref_default_display_name">John Smith</string> <string name="pref_title_add_friends_to_messages">أضف أصدقاء للرسائل</string> <string-array name="pref_example_list_titles"> <item>دائما</item> <item>عندما يكون ذلك ممكن</item> <item>ابدا</item> </string-array> <string-array name="pref_example_list_values"> <item>1</item> <item>0</item> <item>-1</item> </string-array> <!-- Example settings for Data & Sync --> <string name="pref_header_data_sync">بيانات & المزامنة</string> <string name="pref_title_sync_frequency">تكرار المزامنة</string> <string-array name="pref_sync_frequency_titles"> <item>15 دقيقة</item> <item>30 شهر</item> <item>1 ساعه</item> <item>3 ساعه</item> <item>6 ساعه</item> <item>ابدا</item> </string-array> <string-array name="pref_sync_frequency_values"> <item>15</item> <item>30</item> <item>60</item> <item>180</item> <item>360</item> <item>-1</item> </string-array> <string-array name="list_preference_entries"> <item>دخول 1</item> <item>دخول 2</item> <item>دخول 3</item> </string-array> <string-array name="list_preference_entry_values"> <item>1</item> <item>2</item> <item>3</item> </string-array> <string-array name="multi_select_list_preference_default_value" /> <string name="pref_title_system_sync_settings">إعدادات المزامنة النظام</string> <!-- Example settings for Notifications --> <string name="pref_header_notifications">إشعار</string> <string name="pref_title_new_message_notifications">إشعارات الرسائل الجديدة</string> <string name="pref_title_vibrate">اهتزاز</string> <string name="action_settings">الضبط</string> <string name="title_activity_settings">الضبط</string> <string name="pref_title_ringtone">نغمة الرنين</string> <string name="pref_ringtone_silent">صامت</string> <string name="default_gallery_storage">ادخل اسمك</string> <string name="title_auto_upload">تحميل تلقائي</string> <string name="summary_upload_over_wifi">حمّل مقاطع الفيديو عندما تكون شبكة wifi متاحة</string> <string name="title_upload_quality">تحميل الجودة</string> <string name="summary_upload_video_quality">تحديد جودة الفيديو للتحميل</string> <string name="pref_title_notifications">إشعار</string> <string name="summary_choose_ringtone">اختيار صوت الاشعار</string> <string name="pref_header_about">حول</string> <string name="summary_about">اهلا وسهلا بلال المومني مبرمج تطبيقات اندرويد</string> <string name="app_version">3.5</string> <string name="summary_support">هل لديك أية استفسارات!</string> <string name="title_send_feedback">إرسال الملاحظات</string> <string name="title_faq">☎📞</string> <string name="summary_faq">اتصل بنا </string> <string name="url_faq">http://www.boogerbooger.tk/p/contactform2-background-4b4747.html</string> <string name="privacy_policy"> ما هي مدونة بلوجر</string> <string name="url_privacy">http://www.boogerbooger.tk/p/blog-page.html</string> <string name="title_terms">المزيد من اعمالنا</string> <string name="url_terms">http://www.belalalmomanihac.tk</string> <string name="title_version">الاصدار</string> <string name="choose_email_client">البريد الالكتروني</string> <string name="title_gallery_storage">التخزين الافتراضي</string> <string name="title_new_notification_sound">إشعار رسالة جديدة</string> <string name="title_vibrate">اهتزاز</string> <string name="summary_vibrate">اهتزاز على الإشعار الجديد</string> <string name="key_upload_over_wifi">key_upload_over_wifi</string> <string name="key_gallery_name">key_gallery_name</string> <string name="key_upload_quality">key_upload_quality</string> <string name="notifications_new_message">notifications_new_message</string> <string name="key_notifications_new_message_ringtone">key_notifications_new_message_ringtone</string> <string name="key_vibrate">key_vibrate</string> <string name="key_send_feedback">key_send_feedback</string> </resources>
المتابعون
الأربعاء، 12 سبتمبر 2018
خيارات الضبط
الاشتراك في:
تعليقات الرسالة (Atom)
ليست هناك تعليقات:
إرسال تعليق