Exemplo n.º 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);


            Android.Content.Res.AssetManager assets = this.Assets;

            asFuck.LoadList(assets.Open("english-words.txt"), 5);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            EditText wordList            = FindViewById <EditText>(Resource.Id.wordList);
            EditText availableCharacters = FindViewById <EditText>(Resource.Id.input);
            TextView wordsFound          = FindViewById <TextView>(Resource.Id.textWordCount);
            Button   search = FindViewById <Button>(Resource.Id.searchButton);
            Button   soduku = FindViewById <Button>(Resource.Id.sodSolver);


            search.Click += (sender, e) =>
            {
                wordList.Text = string.Empty;
                var matches = asFuck.Find(availableCharacters.Text);
                wordsFound.Text = string.Format("Found {0} words.", matches.Count);
                matches.ForEach(w => wordList.Text += string.Format("{0}\n", w));
            };

            soduku.Click += (sender, e) =>
            {
                var intent = new Intent(this, typeof(SentenceSolver));
                StartActivity(intent);
            };
        }
Exemplo n.º 2
0
        private static bool copyAssetFolder(Android.Content.Res.AssetManager assetManager, String fromAssetPath, String toPath)
        {
            try
            {
                String[] files = assetManager.List(fromAssetPath);
                bool     res   = true;

                if (files.Length == 0)
                {
                    //If it's a file, it won't have any assets "inside" it.
                    res &= copyAsset(assetManager,
                                     fromAssetPath,
                                     toPath);
                }
                else
                {
                    new File(toPath).Mkdirs();
                    foreach (string file in files)
                    {
                        res &= copyAssetFolder(assetManager,
                                               fromAssetPath + "/" + file,
                                               toPath + "/" + file);
                    }
                }
                return(res);
            }
            catch (Java.Lang.Exception e)
            {
                e.PrintStackTrace();
                return(false);
            }
        }
Exemplo n.º 3
0
        private void InitIoC(Android.Content.Res.AssetManager assetManagerssets)
        {
            if (AppSettings.Container == null)
            {
                HttpClient = new ExtendedHttpClient();

                var builder           = new ContainerBuilder();
                var saverService      = new SaverService();
                var dataProvider      = new UserManager(saverService);
                var appInfo           = new AppInfo();
                var assetsHelper      = new AssetHelper(assetManagerssets);
                var connectionService = new ConnectionService();

                var localizationManager = new LocalizationManager(saverService, assetsHelper);
                var configManager       = new ConfigManager(saverService, assetsHelper);

                builder.RegisterInstance(assetsHelper).As <IAssetHelper>().SingleInstance();
                builder.RegisterInstance(appInfo).As <IAppInfo>().SingleInstance();
                builder.RegisterInstance(saverService).As <ISaverService>().SingleInstance();
                builder.RegisterInstance(dataProvider).As <UserManager>().SingleInstance();
                builder.RegisterInstance(connectionService).As <IConnectionService>().SingleInstance();
                builder.RegisterInstance(localizationManager).As <LocalizationManager>().SingleInstance();
                builder.RegisterInstance(configManager).As <ConfigManager>().SingleInstance();
                var configInfo      = assetsHelper.GetConfigInfo();
                var reporterService = new LogService(HttpClient, appInfo, configInfo.RavenClientDsn);
                builder.RegisterInstance(reporterService).As <ILogService>().SingleInstance();
                AppSettings.Container = builder.Build();

                MainChain   = AppSettings.User.Chain;
                SteemClient = new SteepshotApiClient(HttpClient, KnownChains.Steem);
                GolosClient = new SteepshotApiClient(HttpClient, KnownChains.Golos);
            }
        }
Exemplo n.º 4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            var contentHeaderTextView = FindViewById <TextView>(Resource.Id.ContentHeaderTextView);

            contentHeaderTextView.Text = GetText(Resource.String.ContentHeader);

            var clickMeButton        = FindViewById <Button>(Resource.Id.ClickMeButton);
            var clickCounterTextView = FindViewById <TextView>(Resource.Id.ClickCounterTextView);

            clickMeButton.Click += (s, e) =>
            {
                counter++;
                clickCounterTextView.Text = Resources.GetQuantityString(
                    Resource.Plurals.NumberOfClicks, counter, counter);

                var player = Android.Media.MediaPlayer.Create(this, Resource.Raw.sound);
            };

            Android.Content.Res.AssetManager manager = this.Assets;
            using (var reader = new System.IO.StreamReader(manager.Open("Contenido.txt")))
            {
                contentHeaderTextView.Text = $"\n\n{reader.ReadToEnd()}";
            }
        }
Exemplo n.º 5
0
        public static void InitIoC(Android.Content.Res.AssetManager assetManagerssets)
        {
            if (AppSettings.Container == null)
            {
                var builder           = new ContainerBuilder();
                var saverService      = new SaverService();
                var dataProvider      = new UserManager(saverService);
                var appInfo           = new AppInfo();
                var assetsHelper      = new AssetsHelper(assetManagerssets);
                var connectionService = new ConnectionService();

                var localizationManager = new LocalizationManager(saverService, assetsHelper);
                var configManager       = new ConfigManager(saverService, assetsHelper);

                builder.RegisterInstance(assetsHelper).As <IAssetsHelper>().SingleInstance();
                builder.RegisterInstance(appInfo).As <IAppInfo>().SingleInstance();
                builder.RegisterInstance(saverService).As <ISaverService>().SingleInstance();
                builder.RegisterInstance(dataProvider).As <UserManager>().SingleInstance();
                builder.RegisterInstance(connectionService).As <IConnectionService>().SingleInstance();
                builder.RegisterInstance(connectionService).As <IConnectionService>().SingleInstance();
                builder.RegisterInstance(localizationManager).As <LocalizationManager>().SingleInstance();
                builder.RegisterInstance(configManager).As <ConfigManager>().SingleInstance();
                var configInfo      = assetsHelper.GetConfigInfo();
                var reporterService = new ReporterService(appInfo, configInfo.RavenClientDsn);
                builder.RegisterInstance(reporterService).As <IReporterService>().SingleInstance();
                AppSettings.Container = builder.Build();
            }
        }
Exemplo n.º 6
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            var ContentHeader = FindViewById <TextView>(Resource.Id.ContentHeader);

            ContentHeader.Text = GetText(Resource.String.ContentHeader);
            var ClickMe      = FindViewById <Button>(Resource.Id.ClickMe);
            var ClickCounter = FindViewById <TextView>(Resource.Id.ClickCounter);

            ClickMe.Click += (s, ev) =>
            {
                counter++;
                ClickCounter.Text = Resources.GetQuantityString(Resource.Plurals.numberOfClicks, counter, counter);
                var Player = Android.Media.MediaPlayer.Create(this, Resource.Raw.sound);
                Player.Start();
            };

            Android.Content.Res.AssetManager Manager = this.Assets;
            using (var Reader = new System.IO.StreamReader(Manager.Open("Contenido.txt")))
            {
                ContentHeader.Text += $"\n\n{Reader.ReadToEnd()}";
            }

            var ValidarActividadButton = FindViewById <Button>(Resource.Id.ValidateButton);

            ValidarActividadButton.Click += (sender, e) =>
            {
                var Intent = new Android.Content.Intent(this, typeof(ValidarActivity));
                StartActivity(Intent);
            };
        }
Exemplo n.º 7
0
        public List <string> GetStoredInfo(string infoFile)
        {
            //Used to get the contents from the Android Assests and return a List

            List <string> infoFromFile = new List <string>();
            string        content;

            try
            {
                MainActivity activity = new MainActivity();
                Android.Content.Res.AssetManager assets = MainActivity.assets;

                using (StreamReader sr = new StreamReader(assets.Open(infoFile)))

                {
                    while ((content = sr.ReadLine()) != null)
                    {
                        infoFromFile.Add(content.ToString());
                    }
                }

                return(infoFromFile);
            }
            catch (Exception ex)
            {
                //Used for Debugging
                Debug.Print("Error- " + ex.Message);
                throw (ex);
            }
        }
Exemplo n.º 8
0
        public void InitializeConstants(Android.Content.Res.AssetManager assets)
        {
            AEH = Typeface.CreateFromAsset(assets, "AEH.ttf");

            MainRed  = new Color(192, 46, 50);
            MainCyan = new Color(5, 194, 208);
            MainGrey = new Color(48, 64, 63);
        }
Exemplo n.º 9
0
        public void InitAndroid(Android.App.Activity context, Android.Content.Res.AssetManager assetMgr)
        {
            SDK_PlatformAndroid_InitAndroid(CoreObject, Android.Runtime.JNIEnv.Handle, assetMgr.Handle);
            SDK_PlatformAndroid_SetAssetsFileNameCB(mGetAssetsRelativeFileName);

            ExternalFilesDir = context.GetExternalFilesDir(null).AbsolutePath;//这个目录是app再sdcard下的沙箱目录,卸载后会被删除
            //保留AssetManager
            AssetManager = assetMgr;
        }
Exemplo n.º 10
0
 private static byte[] LoadBytesFromStream(string assetsPath, Android.Content.Res.AssetManager assets)
 {
     byte[] bytes;
     using (var assetStream = assets.Open(assetsPath)){
         using (var memoryStream = new MemoryStream()){
             assetStream.CopyTo(memoryStream);
             bytes = memoryStream.ToArray();
         }
     }
     return(bytes);
 }
Exemplo n.º 11
0
        // ----------------------------------------------------------------------------------------------------------------
        // determineCurrentStorage, is very extensible. We have the ability to add any form of
        // storage system, so long as they implement the Storage interface methods.
        // @param identifier will determine what particular Storage system Scar Arcade will be using.
        static public void determineCurrentStorage(int identifier, Android.Content.Res.AssetManager assets)
        {
            switch (identifier)
            {
            case 0:
                currentStorage = new FileStorage(assets);
                break;

            default:
                throw new Exception();
            }
        }
Exemplo n.º 12
0
        protected override void OnCreate(Bundle bundle)
        {
            //thisActivity = this;

            base.OnCreate(bundle);

            //Pass parameters on to Application
            global::Xamarin.Forms.Forms.Init(this, bundle);
            Instance = this;
            assets   = this.Assets;
            Xamarin.Forms.DependencyService.Register <IActivityHelper, ActivityHelper>();
            LoadApplication(new App());
        }
Exemplo n.º 13
0
        public static string ReadHtml(Android.Content.Res.AssetManager assets)
        {
            var body = "";

            using (var stream = assets.Open("content.html"))
            {
                StreamReader sr = new StreamReader(stream);
                body = sr.ReadToEnd();
                sr.Close();
                sr.Dispose();
            }
            return(body);
        }
Exemplo n.º 14
0
        protected override Java.Lang.Object LoadResource(Android.Content.Res.AssetManager p0, string p1)
        {
            var handle = Android.Runtime.InputStreamAdapter.ToLocalJniHandle(LoadFile(p0, p1));

            try
            {
                return(new Java.Lang.Object(handle, Android.Runtime.JniHandleOwnership.TransferLocalRef));
            }
            finally
            {
                Android.Runtime.JNIEnv.DeleteLocalRef(handle);
            }
        }
Exemplo n.º 15
0
        public Setup(Context applicationContext) : base(applicationContext)
        {
            WorkPath = applicationContext.ApplicationInfo.DataDir;
            if (!Directory.Exists(WorkPath))
            {
                Directory.CreateDirectory(WorkPath);
            }
            App._DBPath = Path.Combine(WorkPath, "JoyTify.db");



            /// secret
            Android.Content.Res.AssetManager assets = applicationContext.Assets; string fileName = "client_secrets.json";
            string client_secretsPath = Path.Combine(WorkPath, fileName);

            if (!File.Exists(client_secretsPath))
            {
                using (StreamReader sr = new StreamReader(assets.Open(fileName)))
                {
                    string content = sr.ReadToEnd();
                    File.WriteAllText(client_secretsPath, content);
                }
            }

            /// Token
            fileName = "Google.Apis.Auth.OAuth2.Responses.TokenResponse-user";
            string tokenPath = Path.Combine(WorkPath, fileName);

            if (!File.Exists(tokenPath))
            {
                using (StreamReader sr = new StreamReader(assets.Open(fileName)))
                {
                    string content = sr.ReadToEnd();
                    File.WriteAllText(tokenPath, content);
                }
            }

            /// Cred
            using (var stream = new FileStream(client_secretsPath, FileMode.Open, FileAccess.Read))
            {
                App._CRED = Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.AuthorizeAsync(
                    Google.Apis.Auth.OAuth2.GoogleClientSecrets.Load(stream).Secrets,
                    // This OAuth 2.0 access scope allows for read-only access to the authenticated
                    // user's account, but not other types of account access.
                    new[] { YouTubeService.Scope.Youtube, },
                    "user",
                    CancellationToken.None,
                    new FileDataStore(WorkPath, true)
                    ).Result;
            }
        }
Exemplo n.º 16
0
        public static void GetEnglishLists(Android.Content.Res.AssetManager Assets)
        {
            string       response;
            StreamReader strm = new StreamReader(Assets.Open("AttackTypeChart.txt"));

            response             = strm.ReadToEnd();
            allTypes.attackTypes = JsonConvert.DeserializeObject <List <Type> >(response);

            string       response2;
            StreamReader strm2 = new StreamReader(Assets.Open("DefenseTypeChart.txt"));

            response2             = strm2.ReadToEnd();
            allTypes.defenseTypes = JsonConvert.DeserializeObject <List <Type> >(response2);
        }
Exemplo n.º 17
0
        public static string FileToString(string filename)
        {
            string contents = "";
#if __ANDROID__
      Android.Content.Res.AssetManager assets = MainActivity.TheView.Assets;
      using (StreamReader sr = new StreamReader(assets.Open(filename))) {
        contents = sr.ReadToEnd();
      }
#elif __IOS__
            string[] lines = System.IO.File.ReadAllLines(filename);
            contents = string.Join("\n", lines);
#endif
            return contents;
        }
Exemplo n.º 18
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            //Loads the assets of the application
            assets = this.Assets;

            //Get the list of currencies
            currencies           = APIMethods.GetMarkets();
            currenciesStringList = new List <string>();

            foreach (var currency in currencies)
            {
                currenciesStringList.Add(currency.MarketName);
            }

            Constants.ApiKey    = LoginData.APIKey;
            Constants.SecretKey = LoginData.SecretKey;

            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            //Set the toolbar
            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            toolbar.SetTitleTextColor(Android.Graphics.Color.White);
            SetActionBar(toolbar);
            ActionBar.Title = "Bittrex";

            //Initialise the adapter and search view
            _adapter = new SearchableAdapter(this, currenciesStringList);

            _listView         = this.FindViewById <ListView>(Resource.Id.listView);
            _listView.Adapter = _adapter;

            _listView.ItemClick += _listView_ItemClick;

            var searchView = (SearchView)FindViewById(Resource.Id.searchView);

            _searchView = searchView.JavaCast <SearchView>();

            _searchView.SetIconifiedByDefault(false);
            _searchView.SetBackgroundColor(Android.Graphics.Color.White);
            _searchView.SetQueryHint("Search currencies");

            _searchView.QueryTextChange += (s, e) => _adapter.Filter.InvokeFilter(new Java.Lang.String(e.NewText));
        }
Exemplo n.º 19
0
 private static bool copyAsset(Android.Content.Res.AssetManager assetManager, String fromAssetPath, String toPath)
 {
     try
     {
         using (var input = assetManager.Open(fromAssetPath))
             using (var output = new System.IO.FileStream(toPath, System.IO.FileMode.Create, System.IO.FileAccess.Write))
             {
                 input.CopyTo(output);
             }
         return(true);
     }
     catch (Java.Lang.Exception e)
     {
         e.PrintStackTrace();
         return(false);
     }
 }
Exemplo n.º 20
0
 private string GetResourceString(string ResourceName)
 {
     try
     {
         string content;
         Android.Content.Res.AssetManager assets = this.Assets;
         using (System.IO.StreamReader sr = new System.IO.StreamReader(assets.Open(ResourceName)))
         {
             content = sr.ReadToEnd();
         }
         return(content);
     }
     catch
     {
         throw new Exception("Could not read Resource file!");
     }
 }
Exemplo n.º 21
0
        public static Texture2D GetDefaultFontTexture(GraphicsDevice graphicsDevice)
        {
#if ANDROID
            var activity = FlatRedBallServices.Game.Services.GetService<Android.App.Activity>();

            if(activity == null)
            {
                string message =
                    "As of July 2017, FlatRedBall Android performs a much faster loading of the default font. This requires a change to the Activity1.cs file. You can look at a brand-new Android template to see the required changes.";

                throw new NullReferenceException(message);
            }


            Android.Content.Res.AssetManager androidAssetManager = activity.Assets;
            Texture2D texture;

            try
            {

                using (var stream = androidAssetManager.Open("content/defaultfonttexture.png"))
                {
                    texture = Texture2D.FromStream(graphicsDevice, stream);
                }
            }
            catch
            {
                throw new Exception("The file defaultfonttexture.png in the game's content folder is missing. If you are missing this file, look at the default Android template to see where it should be added (in Assets/content/)");
            }

#else


            var colors = DefaultFontDataColors.GetColorArray();

            Texture2D texture = new Texture2D(graphicsDevice, 256, 128);

			texture.SetData<Microsoft.Xna.Framework.Color>(colors);

#endif

            return texture;
        }
Exemplo n.º 22
0
        public static void LoadLecturers()
        {
            Android.Content.Res.AssetManager assets = Android.App.Application.Context.Assets;
            using (StreamReader reader = new StreamReader(assets.Open("Lecturers.txt")))
            {
                string   text      = reader.ReadToEnd();
                string[] fileLines = text.Split(new[] { Environment.NewLine }, StringSplitOptions.None);

                fileLines.Where(x => !string.IsNullOrEmpty(x)).ToArray();

                for (int i = 0; i + 1 < fileLines.Length; i += 2)
                {
                    lecturers.Add(new Lecturer
                    {
                        Id = Int32.Parse(fileLines[i].Trim()),
                        //Name = fileLines[i + 1].Trim(),
                    });
                }
            }
        }
        /// <summary>
        /// Reads the contents of a text file stored in the app's bundle based on the specified <paramref name="path"/>
        /// </summary>
        /// <param name="path">The file and subfolder path relative to the platform's bundle.
        /// The file needs to be located at a path inside "Assets" for Android and "Resources" for iOS</param>
        /// <returns></returns>
        public static string GetBundledTextFileContent(string path)
        {
#if __IOS__
            var    iosPath = Path.Combine(GetApplicationBundlePath(), path);
            string text;
            using (StreamReader sr = new StreamReader(iosPath))
            {
                text = sr.ReadToEnd();
            }
            return(text);
#elif __ANDROID__
            string text;
            Android.Content.Res.AssetManager assets = Android.App.Application.Context.Assets;
            using (StreamReader sr = new StreamReader(assets.Open(path)))
            {
                text = sr.ReadToEnd();
            }
            return(text);
#endif
        }
Exemplo n.º 24
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            var ContentHeader = FindViewById <TextView>(Resource.Id.ContentHeader);

            ContentHeader.Text = GetText(Resource.String.ContentHeader);

            var ClickMe      = FindViewById <Button>(Resource.Id.ClickMe);
            var btnvalidar   = FindViewById <Button>(Resource.Id.Validar);
            var ClickCounter = FindViewById <TextView>(Resource.Id.ClickCounter);

            ClickMe.Click += (sender, e) =>
            {
                counter++;
                ClickCounter.Text = Resources.GetQuantityString(
                    Resource.Plurals.numberOfClicks, counter, counter);

                var player = Android.Media.MediaPlayer.Create(
                    this, Resource.Raw.sound);

                player.Start();
            };

            btnvalidar.Click += (sender, e) =>
            {
                StartActivity(typeof(Validar));
            };


            Android.Content.Res.AssetManager man = this.Assets;

            using (var Reader =
                       new System.IO.StreamReader(man.Open("Contenido.txt")))
            {
                ContentHeader.Text += $"\n\n{Reader.ReadToEnd()}";
            }
        }
Exemplo n.º 25
0
        public static string ReadHtml(Android.Content.Res.AssetManager assets)
        {
            string content = string.Empty;

            try
            {
                using (var stream = assets.Open("content.html"))
                {
                    StreamReader sr = new StreamReader(stream);
                    content = sr.ReadToEnd();
                    sr.Close();
                    sr.Dispose();
                    return(content);
                }
            }
            catch (Exception ex)
            {
                //todo 异常处理
                return(content);
            }
        }
Exemplo n.º 26
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            var Intent = new Android.Content.Intent(this, typeof(DisenioAndroid));

            var ContentHeader = FindViewById <TextView>(Resource.Id.ContentHeader);

            ContentHeader.Text = GetText(Resource.String.ContentHeader);

            var ClickMe      = FindViewById <Button>(Resource.Id.ClickMe);
            var ClickCounter = FindViewById <TextView>(Resource.Id.ClickCounter);

            ClickMe.Click += (s, e) =>
            {
                Counter++;
                //valor a mostrar y valor que permitira a andorid cual cadena utilizar
                ClickCounter.Text = Resources.GetQuantityString(Resource.
                                                                Plurals.numberOfClicks, Counter, Counter);

                var Player = Android.Media.MediaPlayer.Create(this, Resource.
                                                              Raw.sound);

                Player.Start();
                Android.Content.Res.AssetManager Manager = this.Assets;

                using (var Reader = new System.IO.StreamReader(Manager.Open("Contenido.txt")))
                {
                    ContentHeader.Text += $"\n\n{Reader.ReadToEnd()}";


                    StartActivity(Intent);
                }
            };
        }
Exemplo n.º 27
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.NavRules);

            turnClassSerial = Intent.GetStringExtra("turnClassSerial");;
            UIClassSerial   = Intent.GetStringExtra("UIClassSerial");

            var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);

            if (toolbar != null)
            {
                SetSupportActionBar(toolbar);
                SupportActionBar.SetDisplayHomeAsUpEnabled(false);
                SupportActionBar.SetHomeButtonEnabled(false);
            }

            bottomNavigation = FindViewById <BottomNavigationView>(Resource.Id.bottom_navigation);


            bottomNavigation.NavigationItemSelected += BottomNavigation_NavigationItemSelected;

            try
            {
                bottomNavigation.Menu.GetItem(0).SetChecked(true);
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.Print("Heya:" + ex.Message);
            }


            assets = this.Assets;
        }
Exemplo n.º 28
0
 protected override Java.Lang.Object LoadResource(Android.Content.Res.AssetManager p0, string p1)
 {
     return(LoadFile(p0, p1));
 }
Exemplo n.º 29
0
 // We can simply change were to save the data;
 // private string saveFileLocation = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
 // ----------------------------------------------------------------------------------------------------------------
 // Constructor
 public FileStorage(Android.Content.Res.AssetManager assets)
 {
     this.assets = assets;
 }
Exemplo n.º 30
0
 public AndroidDataStore(Android.Content.Res.AssetManager AssetSource)
 {
     _assets = AssetSource;
 }