Search in sources :

Example 36 with Build

use of android.os.Build in project Awful.apk by Awful.

the class ThreadDisplayFragment method ignoreUser.

/**
 * Add a user to the ignore list.
 *
 * @param userId The awful ID of the user
 */
public void ignoreUser(int userId) {
    final Activity activity = getActivity();
    if (getPrefs().ignoreFormkey == null) {
        queueRequest(new ProfileRequest(activity, null).build());
    }
    if (getPrefs().showIgnoreWarning) {
        DialogInterface.OnClickListener onClickListener = (dialog, which) -> {
            if (which == AlertDialog.BUTTON_NEUTRAL) {
                // cancel future alerts if the user clicks the "don't warn" option
                getPrefs().setPreference(Keys.SHOW_IGNORE_WARNING, false);
            }
            doIgnoreUser(activity, userId);
        };
        new AlertDialog.Builder(activity).setPositiveButton(R.string.confirm, onClickListener).setNeutralButton(R.string.dont_show_again, onClickListener).setNegativeButton(R.string.cancel, null).setTitle(R.string.ignore_title).setMessage(R.string.ignore_message).show();
    } else {
        doIgnoreUser(activity, userId);
    }
}
Also used : JavascriptInterface(android.webkit.JavascriptInterface) IgnoreRequest(com.ferg.awfulapp.task.IgnoreRequest) Constants(com.ferg.awfulapp.constants.Constants) SwipyRefreshLayoutDirection(com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayoutDirection) Bundle(android.os.Bundle) AwfulRequest(com.ferg.awfulapp.task.AwfulRequest) RedirectTask(com.ferg.awfulapp.task.RedirectTask) PackageManager(android.content.pm.PackageManager) MarkLastReadRequest(com.ferg.awfulapp.task.MarkLastReadRequest) AwfulURL(com.ferg.awfulapp.thread.AwfulURL) Uri(android.net.Uri) BookmarkRequest(com.ferg.awfulapp.task.BookmarkRequest) CloseOpenRequest(com.ferg.awfulapp.task.CloseOpenRequest) SwipyRefreshLayout(com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayout) ThreadDisplay(com.ferg.awfulapp.thread.ThreadDisplay) WebViewJsInterface(com.ferg.awfulapp.webview.WebViewJsInterface) StringUtils(org.apache.commons.lang3.StringUtils) Manifest(android.Manifest) CookieManager(android.webkit.CookieManager) Handler(android.os.Handler) Keys(com.ferg.awfulapp.preferences.Keys) Map(java.util.Map) WebViewClient(android.webkit.WebViewClient) View(android.view.View) CookieSyncManager(android.webkit.CookieSyncManager) WebView(android.webkit.WebView) LoaderManager(android.support.v4.app.LoaderManager) ColorProvider(com.ferg.awfulapp.provider.ColorProvider) FloatingActionButton(android.support.design.widget.FloatingActionButton) AwfulUtils(com.ferg.awfulapp.util.AwfulUtils) AsyncTask(android.os.AsyncTask) AwfulThread(com.ferg.awfulapp.thread.AwfulThread) MenuItemCompat(android.support.v4.view.MenuItemCompat) ContextCompat(android.support.v4.content.ContextCompat) PostContextMenu(com.ferg.awfulapp.popupmenu.PostContextMenu) ViewGroup(android.view.ViewGroup) Timber(timber.log.Timber) ContentObserver(android.database.ContentObserver) AwfulError(com.ferg.awfulapp.util.AwfulError) AlertDialog(android.app.AlertDialog) DownloadManager(android.app.DownloadManager) AwfulPost(com.ferg.awfulapp.thread.AwfulPost) List(java.util.List) TextView(android.widget.TextView) InflateException(android.view.InflateException) FragmentActivity(android.support.v4.app.FragmentActivity) SinglePostRequest(com.ferg.awfulapp.task.SinglePostRequest) ReportRequest(com.ferg.awfulapp.task.ReportRequest) Nullable(android.support.annotation.Nullable) Request(android.app.DownloadManager.Request) AwfulMessage(com.ferg.awfulapp.thread.AwfulMessage) Context(android.content.Context) VoteRequest(com.ferg.awfulapp.task.VoteRequest) AwfulProvider(com.ferg.awfulapp.provider.AwfulProvider) Environment(android.os.Environment) DownloadListener(android.webkit.DownloadListener) Intent(android.content.Intent) CursorLoader(android.support.v4.content.CursorLoader) ShareActionProvider(android.support.v7.widget.ShareActionProvider) HashMap(java.util.HashMap) NonNull(android.support.annotation.NonNull) LoggingWebChromeClient(com.ferg.awfulapp.webview.LoggingWebChromeClient) ProfileRequest(com.ferg.awfulapp.task.ProfileRequest) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) NetworkUtils(com.ferg.awfulapp.network.NetworkUtils) PageBar(com.ferg.awfulapp.widget.PageBar) MenuInflater(android.view.MenuInflater) Toast(android.widget.Toast) Menu(android.view.Menu) Build(android.os.Build) LinkedList(java.util.LinkedList) PostRequest(com.ferg.awfulapp.task.PostRequest) DialogInterface(android.content.DialogInterface) Cursor(android.database.Cursor) Formatter(android.text.format.Formatter) UrlContextMenu(com.ferg.awfulapp.popupmenu.UrlContextMenu) Loader(android.support.v4.content.Loader) AwfulTheme(com.ferg.awfulapp.provider.AwfulTheme) LayoutInflater(android.view.LayoutInflater) AwfulPreferences(com.ferg.awfulapp.preferences.AwfulPreferences) AwfulPagedItem(com.ferg.awfulapp.thread.AwfulPagedItem) TYPE(com.ferg.awfulapp.thread.AwfulURL.TYPE) TextUtils(android.text.TextUtils) VolleyError(com.android.volley.VolleyError) ResolveInfo(android.content.pm.ResolveInfo) Color(android.graphics.Color) PagePicker(com.ferg.awfulapp.widget.PagePicker) FragmentManager(android.support.v4.app.FragmentManager) Crashlytics(com.crashlytics.android.Crashlytics) AwfulWebView(com.ferg.awfulapp.webview.AwfulWebView) ImageSizeRequest(com.ferg.awfulapp.task.ImageSizeRequest) Activity(android.app.Activity) EditText(android.widget.EditText) ContentUris(android.content.ContentUris) DialogInterface(android.content.DialogInterface) FragmentActivity(android.support.v4.app.FragmentActivity) Activity(android.app.Activity) ProfileRequest(com.ferg.awfulapp.task.ProfileRequest)

Example 37 with Build

use of android.os.Build in project Awful.apk by Awful.

the class ThreadDisplayFragment method rateThread.

/**
 * Display a thread-rating dialog.
 *
 * This handles the network request to submit the vote, and user feedback.
 */
private void rateThread() {
    final CharSequence[] items = { "1", "2", "3", "4", "5" };
    final Activity activity = this.getActivity();
    new AlertDialog.Builder(activity).setTitle("Rate this thread").setItems(items, (dialog, item) -> queueRequest(new VoteRequest(activity, getThreadId(), item).build(ThreadDisplayFragment.this, new AwfulRequest.AwfulResultCallback<Void>() {

        @Override
        public void success(Void result) {
            getAlertView().setTitle(R.string.vote_succeeded).setSubtitle(R.string.vote_succeeded_sub).setIcon(R.drawable.ic_mood).show();
        }

        @Override
        public void failure(VolleyError error) {
        }
    }))).show();
}
Also used : AlertDialog(android.app.AlertDialog) JavascriptInterface(android.webkit.JavascriptInterface) IgnoreRequest(com.ferg.awfulapp.task.IgnoreRequest) Constants(com.ferg.awfulapp.constants.Constants) SwipyRefreshLayoutDirection(com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayoutDirection) Bundle(android.os.Bundle) AwfulRequest(com.ferg.awfulapp.task.AwfulRequest) RedirectTask(com.ferg.awfulapp.task.RedirectTask) PackageManager(android.content.pm.PackageManager) MarkLastReadRequest(com.ferg.awfulapp.task.MarkLastReadRequest) AwfulURL(com.ferg.awfulapp.thread.AwfulURL) Uri(android.net.Uri) BookmarkRequest(com.ferg.awfulapp.task.BookmarkRequest) CloseOpenRequest(com.ferg.awfulapp.task.CloseOpenRequest) SwipyRefreshLayout(com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayout) ThreadDisplay(com.ferg.awfulapp.thread.ThreadDisplay) WebViewJsInterface(com.ferg.awfulapp.webview.WebViewJsInterface) StringUtils(org.apache.commons.lang3.StringUtils) Manifest(android.Manifest) CookieManager(android.webkit.CookieManager) Handler(android.os.Handler) Keys(com.ferg.awfulapp.preferences.Keys) Map(java.util.Map) WebViewClient(android.webkit.WebViewClient) View(android.view.View) CookieSyncManager(android.webkit.CookieSyncManager) WebView(android.webkit.WebView) LoaderManager(android.support.v4.app.LoaderManager) ColorProvider(com.ferg.awfulapp.provider.ColorProvider) FloatingActionButton(android.support.design.widget.FloatingActionButton) AwfulUtils(com.ferg.awfulapp.util.AwfulUtils) AsyncTask(android.os.AsyncTask) AwfulThread(com.ferg.awfulapp.thread.AwfulThread) MenuItemCompat(android.support.v4.view.MenuItemCompat) ContextCompat(android.support.v4.content.ContextCompat) PostContextMenu(com.ferg.awfulapp.popupmenu.PostContextMenu) ViewGroup(android.view.ViewGroup) Timber(timber.log.Timber) ContentObserver(android.database.ContentObserver) AwfulError(com.ferg.awfulapp.util.AwfulError) AlertDialog(android.app.AlertDialog) DownloadManager(android.app.DownloadManager) AwfulPost(com.ferg.awfulapp.thread.AwfulPost) List(java.util.List) TextView(android.widget.TextView) InflateException(android.view.InflateException) FragmentActivity(android.support.v4.app.FragmentActivity) SinglePostRequest(com.ferg.awfulapp.task.SinglePostRequest) ReportRequest(com.ferg.awfulapp.task.ReportRequest) Nullable(android.support.annotation.Nullable) Request(android.app.DownloadManager.Request) AwfulMessage(com.ferg.awfulapp.thread.AwfulMessage) Context(android.content.Context) VoteRequest(com.ferg.awfulapp.task.VoteRequest) AwfulProvider(com.ferg.awfulapp.provider.AwfulProvider) Environment(android.os.Environment) DownloadListener(android.webkit.DownloadListener) Intent(android.content.Intent) CursorLoader(android.support.v4.content.CursorLoader) ShareActionProvider(android.support.v7.widget.ShareActionProvider) HashMap(java.util.HashMap) NonNull(android.support.annotation.NonNull) LoggingWebChromeClient(com.ferg.awfulapp.webview.LoggingWebChromeClient) ProfileRequest(com.ferg.awfulapp.task.ProfileRequest) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) NetworkUtils(com.ferg.awfulapp.network.NetworkUtils) PageBar(com.ferg.awfulapp.widget.PageBar) MenuInflater(android.view.MenuInflater) Toast(android.widget.Toast) Menu(android.view.Menu) Build(android.os.Build) LinkedList(java.util.LinkedList) PostRequest(com.ferg.awfulapp.task.PostRequest) DialogInterface(android.content.DialogInterface) Cursor(android.database.Cursor) Formatter(android.text.format.Formatter) UrlContextMenu(com.ferg.awfulapp.popupmenu.UrlContextMenu) Loader(android.support.v4.content.Loader) AwfulTheme(com.ferg.awfulapp.provider.AwfulTheme) LayoutInflater(android.view.LayoutInflater) AwfulPreferences(com.ferg.awfulapp.preferences.AwfulPreferences) AwfulPagedItem(com.ferg.awfulapp.thread.AwfulPagedItem) TYPE(com.ferg.awfulapp.thread.AwfulURL.TYPE) TextUtils(android.text.TextUtils) VolleyError(com.android.volley.VolleyError) ResolveInfo(android.content.pm.ResolveInfo) Color(android.graphics.Color) PagePicker(com.ferg.awfulapp.widget.PagePicker) FragmentManager(android.support.v4.app.FragmentManager) Crashlytics(com.crashlytics.android.Crashlytics) AwfulWebView(com.ferg.awfulapp.webview.AwfulWebView) ImageSizeRequest(com.ferg.awfulapp.task.ImageSizeRequest) Activity(android.app.Activity) EditText(android.widget.EditText) ContentUris(android.content.ContentUris) VolleyError(com.android.volley.VolleyError) FragmentActivity(android.support.v4.app.FragmentActivity) Activity(android.app.Activity) VoteRequest(com.ferg.awfulapp.task.VoteRequest)

Example 38 with Build

use of android.os.Build in project realm-java by realm.

the class RealmTests method numberOfVersionsDecreasedOnClose.

// Test for https://github.com/realm/realm-java/issues/6977
@Test
public void numberOfVersionsDecreasedOnClose() {
    realm.close();
    looperThread.runBlocking(() -> {
        int count = 50;
        final CountDownLatch bgThreadDoneLatch = new CountDownLatch(count);
        RealmConfiguration config = configFactory.createConfigurationBuilder().directory(context.getFilesDir()).name("versions-test.realm").maxNumberOfActiveVersions(5).build();
        Realm.deleteRealm(config);
        // Synchronizes between change listener and Background writes so they operate in lockstep.
        AtomicReference<CountDownLatch> guard = new AtomicReference<>(new CountDownLatch(1));
        Realm realm = Realm.getInstance(config);
        looperThread.closeAfterTest(realm);
        realm.addChangeListener(callbackRealm -> {
            // This test catches a bug that caused ObjectStore to pin Realm versions
            // if a TableView was created inside a change notification and no elements
            // in the TableView was accessed.
            RealmResults<AllJavaTypes> query = realm.where(AllJavaTypes.class).findAll();
            guard.get().countDown();
            bgThreadDoneLatch.countDown();
            if (bgThreadDoneLatch.getCount() == 0) {
                looperThread.testComplete();
            }
        });
        // Write a number of transactions in the background in a serial manner
        // in order to create a number of different versions. Done in serial
        // to allow the LooperThread to catch up.
        new Thread(() -> {
            for (int i = 0; i < count; i++) {
                Thread t = new Thread() {

                    @Override
                    public void run() {
                        Realm realm = Realm.getInstance(config);
                        realm.executeTransaction(bgRealm -> {
                        });
                        realm.close();
                    }
                };
                t.start();
                try {
                    t.join();
                    TestHelper.awaitOrFail(guard.get());
                    guard.set(new CountDownLatch(1));
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        }).start();
    });
}
Also used : PrimaryKeyAsBoxedInteger(io.realm.entities.PrimaryKeyAsBoxedInteger) Arrays(java.util.Arrays) NullPrimaryKey(io.realm.objectid.NullPrimaryKey) DefaultValueSetter(io.realm.entities.DefaultValueSetter) Assert.assertNotSame(org.junit.Assert.assertNotSame) Dog(io.realm.entities.Dog) BigDecimal(java.math.BigDecimal) JSONException(org.json.JSONException) Future(java.util.concurrent.Future) DefaultValueFromOtherConstructor(io.realm.entities.DefaultValueFromOtherConstructor) StringOnly(io.realm.entities.StringOnly) Looper(android.os.Looper) NoPrimaryKeyNullTypes(io.realm.entities.NoPrimaryKeyNullTypes) DefaultValueOfField(io.realm.entities.DefaultValueOfField) NonLatinFieldNames(io.realm.entities.NonLatinFieldNames) PrimaryKeyAsBoxedByte(io.realm.entities.PrimaryKeyAsBoxedByte) InstrumentationRegistry(androidx.test.platform.app.InstrumentationRegistry) Executors(java.util.concurrent.Executors) InvocationTargetException(java.lang.reflect.InvocationTargetException) CountDownLatch(java.util.concurrent.CountDownLatch) Assert.assertFalse(org.junit.Assert.assertFalse) Mockito.mock(org.mockito.Mockito.mock) FilenameFilter(java.io.FilenameFilter) RealmFileException(io.realm.exceptions.RealmFileException) RunWith(org.junit.runner.RunWith) SystemClock(android.os.SystemClock) Callable(java.util.concurrent.Callable) PrimaryKeyAsBoxedShort(io.realm.entities.PrimaryKeyAsBoxedShort) ArrayList(java.util.ArrayList) Assert.assertSame(org.junit.Assert.assertSame) Answer(org.mockito.stubbing.Answer) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Decimal128(org.bson.types.Decimal128) Before(org.junit.Before) TestHelper.testOneObjectFound(io.realm.TestHelper.testOneObjectFound) RealmMigrationNeededException(io.realm.exceptions.RealmMigrationNeededException) PrimaryKeyAsLong(io.realm.entities.PrimaryKeyAsLong) RealmLog(io.realm.log.RealmLog) Assert.assertTrue(org.junit.Assert.assertTrue) AssertionFailedError(junit.framework.AssertionFailedError) Test(org.junit.Test) IOException(java.io.IOException) RealmThread(io.realm.util.RealmThread) DefaultValueConstructor(io.realm.entities.DefaultValueConstructor) File(java.io.File) ExecutionException(java.util.concurrent.ExecutionException) AtomicLong(java.util.concurrent.atomic.AtomicLong) OsSharedRealm(io.realm.internal.OsSharedRealm) Assert.assertNull(org.junit.Assert.assertNull) TestHelper.testNoObjectFound(io.realm.TestHelper.testNoObjectFound) Owner(io.realm.entities.Owner) PrimaryKeyRequiredAsBoxedByte(io.realm.entities.PrimaryKeyRequiredAsBoxedByte) UiThreadTest(androidx.test.annotation.UiThreadTest) ObjectId(org.bson.types.ObjectId) CyclicTypePrimaryKey(io.realm.entities.CyclicTypePrimaryKey) Assert.assertEquals(org.junit.Assert.assertEquals) AllTypesPrimaryKey(io.realm.entities.AllTypesPrimaryKey) CoreMatchers(org.hamcrest.CoreMatchers) UiThreadTestRule(androidx.test.rule.UiThreadTestRule) AllJavaTypes(io.realm.entities.AllJavaTypes) Date(java.util.Date) DefaultValueOverwriteNullLink(io.realm.entities.DefaultValueOverwriteNullLink) Scanner(java.util.Scanner) Random(java.util.Random) AndroidJUnit4(androidx.test.ext.junit.runners.AndroidJUnit4) ExtraTests.assertArrayEquals(io.realm.internal.test.ExtraTests.assertArrayEquals) Assert.assertThat(org.junit.Assert.assertThat) JSONObject(org.json.JSONObject) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) After(org.junit.After) Assert.fail(org.junit.Assert.fail) Pair(io.realm.internal.util.Pair) StringOnlyReadOnly(io.realm.entities.StringOnlyReadOnly) OwnerPrimaryKey(io.realm.entities.OwnerPrimaryKey) UUID(java.util.UUID) RealmPrimaryKeyConstraintException(io.realm.exceptions.RealmPrimaryKeyConstraintException) PrimaryKeyAsBoxedLong(io.realm.entities.PrimaryKeyAsBoxedLong) Objects(java.util.Objects) List(java.util.List) PrimaryKeyRequiredAsString(io.realm.entities.PrimaryKeyRequiredAsString) BlockingLooperThread(io.realm.rule.BlockingLooperThread) StringAndInt(io.realm.entities.StringAndInt) Context(android.content.Context) RandomPrimaryKey(io.realm.entities.RandomPrimaryKey) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) RealmException(io.realm.exceptions.RealmException) AtomicReference(java.util.concurrent.atomic.AtomicReference) PrimaryKeyRequiredAsBoxedShort(io.realm.entities.PrimaryKeyRequiredAsBoxedShort) Assume(org.junit.Assume) Build(android.os.Build) ExpectedException(org.junit.rules.ExpectedException) ExecutorService(java.util.concurrent.ExecutorService) PrimaryKeyRequiredAsBoxedLong(io.realm.entities.PrimaryKeyRequiredAsBoxedLong) PrimaryKeyRequiredAsBoxedInteger(io.realm.entities.PrimaryKeyRequiredAsBoxedInteger) Assert.assertNotNull(org.junit.Assert.assertNotNull) AllTypes(io.realm.entities.AllTypes) Mockito.when(org.mockito.Mockito.when) CyclicType(io.realm.entities.CyclicType) Object4957(io.realm.entities.Object4957) Cat(io.realm.entities.Cat) TimeUnit(java.util.concurrent.TimeUnit) PrimaryKeyAsString(io.realm.entities.PrimaryKeyAsString) PrimaryKeyMix(io.realm.entities.PrimaryKeyMix) Rule(org.junit.Rule) Ignore(org.junit.Ignore) StrictMode(android.os.StrictMode) DogPrimaryKey(io.realm.entities.DogPrimaryKey) JSONArray(org.json.JSONArray) TemporaryFolder(org.junit.rules.TemporaryFolder) InputStream(java.io.InputStream) AtomicReference(java.util.concurrent.atomic.AtomicReference) CountDownLatch(java.util.concurrent.CountDownLatch) RealmThread(io.realm.util.RealmThread) BlockingLooperThread(io.realm.rule.BlockingLooperThread) AllJavaTypes(io.realm.entities.AllJavaTypes) OsSharedRealm(io.realm.internal.OsSharedRealm) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 39 with Build

use of android.os.Build in project realm-java by realm.

the class RealmTests method encryption_stressTest.

// Test for https://github.com/realm/realm-java/issues/6152
@Test
// See https://github.com/realm/realm-java/issues/7628
@Ignore
public void encryption_stressTest() {
    realm.close();
    looperThread.runBlocking(() -> {
        final int WRITER_TRANSACTIONS = 50;
        final int TEST_OBJECTS = 100_000;
        final int MAX_STRING_LENGTH = 1000;
        final AtomicInteger id = new AtomicInteger(0);
        long seed = System.nanoTime();
        Random random = new Random(seed);
        RealmConfiguration config = configFactory.createConfigurationBuilder().name("encryption-stress-test.realm").encryptionKey(TestHelper.getRandomKey(seed)).build();
        Realm.deleteRealm(config);
        Thread t = new Thread(new Runnable() {

            @Override
            public void run() {
                Realm realm = Realm.getInstance(config);
                for (int i = 0; i < WRITER_TRANSACTIONS; i++) {
                    realm.executeTransaction(r -> {
                        for (int j = 0; j < (TEST_OBJECTS / WRITER_TRANSACTIONS); j++) {
                            AllJavaTypes obj = new AllJavaTypes(id.incrementAndGet());
                            obj.setFieldString(TestHelper.getRandomString(random.nextInt(MAX_STRING_LENGTH)));
                            r.insert(obj);
                        }
                    });
                }
                realm.close();
            }
        });
        t.start();
        Realm realm = Realm.getInstance(config);
        looperThread.closeAfterTest(realm);
        RealmResults<AllJavaTypes> results = realm.where(AllJavaTypes.class).findAllAsync();
        looperThread.keepStrongReference(results);
        results.addChangeListener(new OrderedRealmCollectionChangeListener<RealmResults<AllJavaTypes>>() {

            @Override
            public void onChange(RealmResults<AllJavaTypes> results, OrderedCollectionChangeSet changeSet) {
                for (AllJavaTypes obj : results) {
                    String s = obj.getFieldString();
                }
                if (results.size() == TEST_OBJECTS) {
                    try {
                        t.join(5000);
                    } catch (InterruptedException e) {
                        fail("workerthread failed to finish in time.");
                    }
                    looperThread.testComplete();
                }
            }
        });
    });
}
Also used : PrimaryKeyAsBoxedInteger(io.realm.entities.PrimaryKeyAsBoxedInteger) Arrays(java.util.Arrays) NullPrimaryKey(io.realm.objectid.NullPrimaryKey) DefaultValueSetter(io.realm.entities.DefaultValueSetter) Assert.assertNotSame(org.junit.Assert.assertNotSame) Dog(io.realm.entities.Dog) BigDecimal(java.math.BigDecimal) JSONException(org.json.JSONException) Future(java.util.concurrent.Future) DefaultValueFromOtherConstructor(io.realm.entities.DefaultValueFromOtherConstructor) StringOnly(io.realm.entities.StringOnly) Looper(android.os.Looper) NoPrimaryKeyNullTypes(io.realm.entities.NoPrimaryKeyNullTypes) DefaultValueOfField(io.realm.entities.DefaultValueOfField) NonLatinFieldNames(io.realm.entities.NonLatinFieldNames) PrimaryKeyAsBoxedByte(io.realm.entities.PrimaryKeyAsBoxedByte) InstrumentationRegistry(androidx.test.platform.app.InstrumentationRegistry) Executors(java.util.concurrent.Executors) InvocationTargetException(java.lang.reflect.InvocationTargetException) CountDownLatch(java.util.concurrent.CountDownLatch) Assert.assertFalse(org.junit.Assert.assertFalse) Mockito.mock(org.mockito.Mockito.mock) FilenameFilter(java.io.FilenameFilter) RealmFileException(io.realm.exceptions.RealmFileException) RunWith(org.junit.runner.RunWith) SystemClock(android.os.SystemClock) Callable(java.util.concurrent.Callable) PrimaryKeyAsBoxedShort(io.realm.entities.PrimaryKeyAsBoxedShort) ArrayList(java.util.ArrayList) Assert.assertSame(org.junit.Assert.assertSame) Answer(org.mockito.stubbing.Answer) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Decimal128(org.bson.types.Decimal128) Before(org.junit.Before) TestHelper.testOneObjectFound(io.realm.TestHelper.testOneObjectFound) RealmMigrationNeededException(io.realm.exceptions.RealmMigrationNeededException) PrimaryKeyAsLong(io.realm.entities.PrimaryKeyAsLong) RealmLog(io.realm.log.RealmLog) Assert.assertTrue(org.junit.Assert.assertTrue) AssertionFailedError(junit.framework.AssertionFailedError) Test(org.junit.Test) IOException(java.io.IOException) RealmThread(io.realm.util.RealmThread) DefaultValueConstructor(io.realm.entities.DefaultValueConstructor) File(java.io.File) ExecutionException(java.util.concurrent.ExecutionException) AtomicLong(java.util.concurrent.atomic.AtomicLong) OsSharedRealm(io.realm.internal.OsSharedRealm) Assert.assertNull(org.junit.Assert.assertNull) TestHelper.testNoObjectFound(io.realm.TestHelper.testNoObjectFound) Owner(io.realm.entities.Owner) PrimaryKeyRequiredAsBoxedByte(io.realm.entities.PrimaryKeyRequiredAsBoxedByte) UiThreadTest(androidx.test.annotation.UiThreadTest) ObjectId(org.bson.types.ObjectId) CyclicTypePrimaryKey(io.realm.entities.CyclicTypePrimaryKey) Assert.assertEquals(org.junit.Assert.assertEquals) AllTypesPrimaryKey(io.realm.entities.AllTypesPrimaryKey) CoreMatchers(org.hamcrest.CoreMatchers) UiThreadTestRule(androidx.test.rule.UiThreadTestRule) AllJavaTypes(io.realm.entities.AllJavaTypes) Date(java.util.Date) DefaultValueOverwriteNullLink(io.realm.entities.DefaultValueOverwriteNullLink) Scanner(java.util.Scanner) Random(java.util.Random) AndroidJUnit4(androidx.test.ext.junit.runners.AndroidJUnit4) ExtraTests.assertArrayEquals(io.realm.internal.test.ExtraTests.assertArrayEquals) Assert.assertThat(org.junit.Assert.assertThat) JSONObject(org.json.JSONObject) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) After(org.junit.After) Assert.fail(org.junit.Assert.fail) Pair(io.realm.internal.util.Pair) StringOnlyReadOnly(io.realm.entities.StringOnlyReadOnly) OwnerPrimaryKey(io.realm.entities.OwnerPrimaryKey) UUID(java.util.UUID) RealmPrimaryKeyConstraintException(io.realm.exceptions.RealmPrimaryKeyConstraintException) PrimaryKeyAsBoxedLong(io.realm.entities.PrimaryKeyAsBoxedLong) Objects(java.util.Objects) List(java.util.List) PrimaryKeyRequiredAsString(io.realm.entities.PrimaryKeyRequiredAsString) BlockingLooperThread(io.realm.rule.BlockingLooperThread) StringAndInt(io.realm.entities.StringAndInt) Context(android.content.Context) RandomPrimaryKey(io.realm.entities.RandomPrimaryKey) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) RealmException(io.realm.exceptions.RealmException) AtomicReference(java.util.concurrent.atomic.AtomicReference) PrimaryKeyRequiredAsBoxedShort(io.realm.entities.PrimaryKeyRequiredAsBoxedShort) Assume(org.junit.Assume) Build(android.os.Build) ExpectedException(org.junit.rules.ExpectedException) ExecutorService(java.util.concurrent.ExecutorService) PrimaryKeyRequiredAsBoxedLong(io.realm.entities.PrimaryKeyRequiredAsBoxedLong) PrimaryKeyRequiredAsBoxedInteger(io.realm.entities.PrimaryKeyRequiredAsBoxedInteger) Assert.assertNotNull(org.junit.Assert.assertNotNull) AllTypes(io.realm.entities.AllTypes) Mockito.when(org.mockito.Mockito.when) CyclicType(io.realm.entities.CyclicType) Object4957(io.realm.entities.Object4957) Cat(io.realm.entities.Cat) TimeUnit(java.util.concurrent.TimeUnit) PrimaryKeyAsString(io.realm.entities.PrimaryKeyAsString) PrimaryKeyMix(io.realm.entities.PrimaryKeyMix) Rule(org.junit.Rule) Ignore(org.junit.Ignore) StrictMode(android.os.StrictMode) DogPrimaryKey(io.realm.entities.DogPrimaryKey) JSONArray(org.json.JSONArray) TemporaryFolder(org.junit.rules.TemporaryFolder) InputStream(java.io.InputStream) PrimaryKeyRequiredAsString(io.realm.entities.PrimaryKeyRequiredAsString) PrimaryKeyAsString(io.realm.entities.PrimaryKeyAsString) RealmThread(io.realm.util.RealmThread) BlockingLooperThread(io.realm.rule.BlockingLooperThread) Random(java.util.Random) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AllJavaTypes(io.realm.entities.AllJavaTypes) OsSharedRealm(io.realm.internal.OsSharedRealm) Ignore(org.junit.Ignore) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 40 with Build

use of android.os.Build in project Signal-Android by signalapp.

the class Megaphones method buildNotificationsMegaphone.

@NonNull
private static Megaphone buildNotificationsMegaphone(@NonNull Context context) {
    return new Megaphone.Builder(Event.NOTIFICATIONS, Megaphone.Style.BASIC).setTitle(R.string.NotificationsMegaphone_turn_on_notifications).setBody(R.string.NotificationsMegaphone_never_miss_a_message).setImage(R.drawable.megaphone_notifications_64).setActionButton(R.string.NotificationsMegaphone_turn_on, (megaphone, controller) -> {
        if (Build.VERSION.SDK_INT >= 26 && !NotificationChannels.isMessageChannelEnabled(context)) {
            Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS);
            intent.putExtra(Settings.EXTRA_CHANNEL_ID, NotificationChannels.getMessagesChannel(context));
            intent.putExtra(Settings.EXTRA_APP_PACKAGE, context.getPackageName());
            controller.onMegaphoneNavigationRequested(intent);
        } else if (Build.VERSION.SDK_INT >= 26 && (!NotificationChannels.areNotificationsEnabled(context) || !NotificationChannels.isMessagesChannelGroupEnabled(context))) {
            Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS);
            intent.putExtra(Settings.EXTRA_APP_PACKAGE, context.getPackageName());
            controller.onMegaphoneNavigationRequested(intent);
        } else {
            controller.onMegaphoneNavigationRequested(AppSettingsActivity.notifications(context));
        }
    }).setSecondaryButton(R.string.NotificationsMegaphone_not_now, (megaphone, controller) -> controller.onMegaphoneSnooze(Event.NOTIFICATIONS)).build();
}
Also used : SignalStore(org.thoughtcrime.securesms.keyvalue.SignalStore) Context(android.content.Context) Stream(com.annimon.stream.Stream) NonNull(androidx.annotation.NonNull) LocalDateTime(java.time.LocalDateTime) WorkerThread(androidx.annotation.WorkerThread) Intent(android.content.Intent) R(org.thoughtcrime.securesms.R) LinkedHashMap(java.util.LinkedHashMap) LocaleFeatureFlags(org.thoughtcrime.securesms.util.LocaleFeatureFlags) SignalPinReminders(org.thoughtcrime.securesms.lock.SignalPinReminders) NotificationChannels(org.thoughtcrime.securesms.notifications.NotificationChannels) TranslationDetection(org.signal.core.util.TranslationDetection) Locale(java.util.Locale) Map(java.util.Map) Badge(org.thoughtcrime.securesms.badges.models.Badge) Settings(android.provider.Settings) Recipient(org.thoughtcrime.securesms.recipients.Recipient) KbsMigrationActivity(org.thoughtcrime.securesms.lock.v2.KbsMigrationActivity) Build(android.os.Build) PlayServicesUtil(org.thoughtcrime.securesms.util.PlayServicesUtil) AppSettingsActivity(org.thoughtcrime.securesms.components.settings.app.AppSettingsActivity) MegaphoneRecord(org.thoughtcrime.securesms.database.model.MegaphoneRecord) AvatarHelper(org.thoughtcrime.securesms.profiles.AvatarHelper) Month(java.time.Month) ApplicationDependencies(org.thoughtcrime.securesms.dependencies.ApplicationDependencies) Set(java.util.Set) NetworkConstraint(org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint) DynamicLanguageContextWrapper(org.thoughtcrime.securesms.util.dynamiclanguage.DynamicLanguageContextWrapper) SetUtil(org.thoughtcrime.securesms.util.SetUtil) CreateKbsPinActivity(org.thoughtcrime.securesms.lock.v2.CreateKbsPinActivity) SignalPinReminderDialog(org.thoughtcrime.securesms.lock.SignalPinReminderDialog) Objects(java.util.Objects) TimeUnit(java.util.concurrent.TimeUnit) Log(org.signal.core.util.logging.Log) FeatureFlags(org.thoughtcrime.securesms.util.FeatureFlags) List(java.util.List) Nullable(androidx.annotation.Nullable) VersionTracker(org.thoughtcrime.securesms.util.VersionTracker) ChatWallpaperActivity(org.thoughtcrime.securesms.wallpaper.ChatWallpaperActivity) ManageProfileActivity(org.thoughtcrime.securesms.profiles.manage.ManageProfileActivity) Intent(android.content.Intent) NonNull(androidx.annotation.NonNull)

Aggregations

Build (android.os.Build)42 Context (android.content.Context)30 Intent (android.content.Intent)22 List (java.util.List)22 PackageManager (android.content.pm.PackageManager)20 ArrayList (java.util.ArrayList)19 View (android.view.View)16 Toast (android.widget.Toast)15 File (java.io.File)15 Bundle (android.os.Bundle)14 Uri (android.net.Uri)13 TextView (android.widget.TextView)13 Locale (java.util.Locale)13 Manifest (android.Manifest)11 SharedPreferences (android.content.SharedPreferences)11 NonNull (android.support.annotation.NonNull)11 Activity (android.app.Activity)10 DialogInterface (android.content.DialogInterface)10 EditText (android.widget.EditText)10 Arrays (java.util.Arrays)10