Thursday, August 13, 2015

Installing Windows 10: Problems and Solutions

    Its been a little over a week since Microsoft released Windows 10 for the general public, and more than 14 million people worldwide have upgraded their PCs to Windows 10. With Microsoft announcing that the upgrade from Windows 7,8,8.1 would be free for a year, everyone is upgrading to the new and improved version of Microsoft's Windows.

  Whether it is the customizable start menu, the sleek new looks or the newly introduced Microsoft's voice assistant Cortana, windows 10 is high in demands. 
Windows 10 looks to be better than Windows 7 or 8 in many aspects. The Start menu is back, and is customizable to a great extent. It doesn't take up all the space on your screen, and can be re-sized as per your need. It takes Multitasking to a whole new level, now allowing upto 4 apps to be snapped on the same screen at a time. It also offers multiple desktops now, so one can keep their personal and professional environments separate. With Windows 10, Microsoft has also introduced its Personal Assistant Cortana, which was previously only available on Windows Phones. Cortana can search web for various queries, but also handles core commands like opening a browser, creating a new email, setting reminders or calendar appointments, etc. Though Cortana is no way near Siri's level, its still a welcome and an exciting addition in this version of Windows. For Gamers, Windows 10 is a delight. Windows 10 offers full integration with Microsoft’s Xbox Live network and the Xbox games store. This means Xbox One players can play games with those on PC, and almost every Xbox One title will be available for play on Windows 10. It also supports DirectX12, which is poised to have several performance upgrades, new graphical features and a much improved performance, much to the delight of hardcore PC gamers. It also offers a tablet mode, which should make your experience fun if you have a touchscreen. And to top it all, its FREE! All in all, Windows 10 looks like a serious step up from Windows 8.1 and is worth upgrading to!


You can download Windows 10 in two ways:

• By using the "reserve your Windows 10" notification on your taskbar, or
• By using the ISO provided by Microsoft.

In case the 'upgrade to Windows 10' icon is missing from your taskbar, you won't be able to download Windows 10. In such cases, make sure you do the following things:

• Make sure your Windows copy is genuine. The icon won't appear on pirated versions.

• Make sure you PC meets Windows 10's System Requirements (really no point of continuing if you fail here :P).

• Make sure your PC is up to date. Install all Windows updates from the control Panel.

• Install all the recommended updates and restart your PC, because installation of Windows 10 option won't be available unless your computer is fully updated.
If you are using Windows 7, you must have SP1 (Service Pack 1). installed. If you don't have SP1 in Windows 7, you'll not get the upgrade app and its icon.
Windows 8 users must upgrade to Windows 8.1 to be able to get the Windows 10 upgrade icon. 

• If you have removed Internet Explorer using "Control Panel -> Programs and Features -> Turn Windows features on or off" option, you'll have to re-enable it. Once you re-enable Internet Explorer, run Windows Update and Windows will find and install the required updates to show Windows 10 upgrade app icon.

• If your computer is a part of a domain or network, you'll not see the Windows 10 upgrade icon.


If you still don't see the update Windows icon on the taskbar after installing all the updates, goto command prompt and type this command.

wuauclt.exe/update_now


This should automatically trigger the Windows 10 download. 



After the download is complete, it'll automatically start the installation process. In case the installation fails, just restart the you computer, and this time you should see the update icon.




    In case somehow your computer still isn't showing the icon, don't panic!
Try this solution which is provided by Yaqub Khan - Microsoft Support Engineer.

    We create a script which will verify your device meets all the prerequisites and then turn on the Get Windows 10 app:

1.Open Notepad
2.Copy the following text and paste it into Notepad:

REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\UpgradeExperienceIndicators" /v UpgEx | findstr UpgEx
if "%errorlevel%" == "0" GOTO RunGWX
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Appraiser" /v UtcOnetimeSend /t REG_DWORD /d 1 /f
schtasks /run /TN "\Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser"
:CompatCheckRunning
schtasks /query /TN "\Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser"
schtasks /query /TN "\Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" | findstr Ready
if NOT "%errorlevel%" == "0" ping localhost >nul &goto :CompatCheckRunning
:RunGWX
schtasks /run /TN "\Microsoft\Windows\Setup\gwx\refreshgwxconfig"

3.Click File, and then Save As
4.In the File name box, change the file name to ReserveWin10.cmd
5.Then click the dropdown next to Save as type, and select All files (*.*)
6.Select the folder you would like to save the file to.  For this example, let’s choose to save the file to the C:/Temp folder.  Then click Save. 

7.Open an elevated command prompt.  (From the Start screen or Start menu, type Command Prompt in the search box, and then in the list of results, right-click Command Prompt, and select Run as administrator.)

8.Finally, run the file from the location you saved to in Step 6.  In this example, you would type the following in the Command Prompt window and hit Enter:
C:/Temp/ReserveWin10.cmd

    The Microsoft Compatibility Appraiser can take 10 – 30 minutes to run, during which the script will continuously provide status reports that it is running. Please be patient. If the script is failing in an infinite loop, then you don’t have the necessary prerequisite Windows Updates.  Besides requiring Windows 7 SP1 or Windows 8.1 Update, you must also have installed:

For Windows 7 SP1:
KB3035583
KB2952664

For Windows 8.1 Update:
KB3035583
KB2976978

You can manually check if you have these updates within your elevated command prompt by typing the command:

dism /online /get-packages | findstr 3035583

(Replace the KB number with whichever update you are looking for.)  If you have the update installed, this command will show the package identity.  For example, Windows 8.1 users should see this:

C:\>dism /online /get-packages | findstr 3035583

Package  Identity : Package_for_KB3035583~31bf3856ad364e35~amd64~~6.3.1.29

This should do it for you! Enjoy your newly upgraded PC with Windows 10!!


References : Microsoft Answers

Sunday, July 19, 2015

Trip to the Indian Museum, Kolkata

    So it's nearly the end of summer holidays and I was disappointed that I didn't travel to any place. Most of my summer went into packing and unpacking stuff, because my father says transferred to another place. So anyways, I had big plans for this summer, wanted to go to different places, but this transfer rendered my plans pointless.

    Last Saturday morning, a sudden urge of going somewhere ate me up. I had to go somewhere. I started planning places to go, but the last minute reservations created a big problem. Suddenly I realized, I was just 2 hours away from Kolkata. My native place, my city. I haven't even traveled the city I belong to. So I decided to visit Kolkata the next day.

   There were so many places to visit in Kolkata. I was confused about the places I wanted to visit. So I asked one of my friends for suggestions. He said, "you're a science guy, go to the science city an the museum" (oh boy I wish I didn't listen to him about going to science city, but anyways, that comes later). So, I decided to go to the Indian Museum the first day. So, I left my home early morning at 6am to catch one of the local trains to Howrah (yes, those super crowded ones which are only topped by the Mumbai locals) Needless to say, it was so crowded I could barely stand in the whole 2 hour journey. Anyways, I reached at around 9am to the Howrah station and decided against a Pre-paid taxi and opted for a bus. The bus stop was no different than a fish market, and I got lost in the crowd. Somehow, I found a person who told me which bus to take and I somehow got into that crowded bus again. 


local train


    My first stop was the General Post Office in the Dalhousie Square, as I needed to post a letter to a really close friend. But I was aware of the fact that it was also a tourist attraction, as it was one of the biggest Post Offices in the country and the biggest in the state. Apart from that, the building was designed by Walter Granville, who also designed the high Court, the Indian Museum and the 11 souls memorial church. I was pretty excited to see it, because I never imagined a "post office" being so big and beautiful and an exquisite piece of art. So, when I stepped down the bus at Dalhousie square, I looked around trying to figure out where the GPO was. The area was full of tall building and unusually high traffic. After walking a few meters, I finally saw its prominent domed roof.


GPO, a road view

GPO front view

 It was way bigger than what I expected. The building was alluring and the architecture was commendable. It was a cloudy day, so the overall view was pretty majestic. I was wandering around, looking for the entrance when I noticed this....

Milestone GPO

Brass Lines


    Interesting.... Old Fort William. I didn't even notice the brass lines on the steps until I read it. Well, I googled it put of curiosity and came to know that the GPO was actually built where the Old Fort William used to be, which was destroyed after Siraj-ud-Daula was sacked. It is also believed that the famous 'Black Hole Incident' took place there.  After that, I visited the philatelic bureau, which is supposed to be a stamp collectors delight, but it was surprisingly uncrowded. In-fact I didn't even see a single person in there. Anyways, I posted my letter, admired the beauty of the place for sometime and left. 


statue in philatelic office


    While walking down the street, I saw the Writers' Building. A huge red building stretched across the Lal-Dighi.


Writers' Building

   The building's architecture was engaging, with long verandas supported by iconic columns and consisting of various statues of Minerva and other Greek gods. It is the secretariat building of the State Government of West Bengal, but it was under renovation and thus the departments weren't there. I wanted to take a closer look, but the guards there were quite rude. Ah, who cares about them. I clicked a picture and moved on.


Minerva StatueGreek god statue

    Next was the Royal Insurance Building. For a moment, I almost confused it with the Writers' building. This was another huge building with the gate at the corner. Interestingly enough, this building has a twin in Liverpool, but this is in a much better condition. 


Royal Insurance Building


    I asked people for the directions to the Indian Museum. "Jaadu Ghar?(Hindi for Magic house), that's on Park Street". I said I wanted to go to the museum, not the magic house. After asking 2-3 people, I realized the museum is called the jaadughar by the localites. Now what was so special about this place that people actually called it the magic house. I was more curious now. So, I hailed a cab after that, and decided to go straight to the Indian Museum. The cabby told me it is the largest and the oldest museum in India(which is a true fact), which further fueled my anticipation to see the place. The cab dropped me on the gate, which had huge open market on both sides.


Indian museum poster


    Anyways, I went to the ticket counter too buy the tickets. The entry ticket was only 10 rupees, but photography was restricted. If one wanted to use any kind of camera, he needed to buy another photography ticket worth 50 bucks, which I felt was quite strange. Anyways, I entered the premises and went to the Archaeology section. It was filled with fossils from different prehistoric animals. It was very well documented, and well organised. The casts were carefully and meticulousy placed in the hall. It was a paleophile's delight. The thing that especially caught my eyes was Palaeoloxodon namadicus, extinct elephant, which was placed just at the starting of the gate.

tortoiseextinct elephant

    Next I moved into the history section. It consisted of many statues, idols and paintings. There was a considerable number of statues that were related to Buddha and Buddhism. Then, there was the Bharhut Gallery, full of stone carvings.  It had the architectural remains from Bharhut belonging to Sunga period, along with similar fragments from Bodhgaya.


bharhut gallerybuddha statue

stone carving

mahavira stone carving

bharhut gallery


    The next was the Coin Collections, the section I was really excited about. And the museum didn't disappoint. It had coins from different regions of the Indian subcontinent and range in dates from fourth century BC to present date. Not only it had coins from the Indian subcontinent, it also had coins from other subcontinent too. It was particularly fascinating to me, as I'm a numismatist :P

ancient coins by british rulers

ancient coins by indian rulers

Ancient Greek Coins

    The museum was bigger than we expected. It took almost 2 hours to go through the ground floor, before I realized that there was another floor to cover.
  
inside view of Indian Museum

The particularly interesting section was the animal section. There were replicas of various exotic animals from all around the world. Mammals, reptiles, birds, fish. You name them, you'll find them.

reptiles

crocodiles

blue merlin fish

bird


    The prehistoric skeletons of various mammals were also on display, most notable being the tall mammoth structure and the dinosaur. It had pretty much everything you can possibly expect from a museum. Despite the fact that the day I went, many exhibits weren't present due to renovation work. But still, it engaged me for hours,long enough to make me cancel the plans to go to science city that day.


skeleton of a hippo

skeleton of a mammoth

reindeer skeleton


    Then there was the Egyptian section. Small section, but contained a 4000 year old mummy, the oldest one present in the country. The center piece was the center of attraction. 


statue of egyptian god

4000 year old mummy

Tutankhamun bust

There were just too many things to see. It was like every time I came out of a section, there was a new part waiting to amaze me. There was so much to learn, and so much to see. It had everything, human evolution, art, textile, memorabilia ...everything! I wandered there until 4.30pm, and then after finally completing the tour, I decided to go back home.


embryos

kali statue


castle

ashoka chakranataraja


    At the end of the day, I was heading back to the station to catch my train back home. But that day, a rare thing happened, which truly made my trip unique. While passing through the Howrah bridge, I saw a huge crowd looking and pointing towards the sky. For a moment, I was thinking what the hell are these people looking at. Most of the people actually had no idea what they were looking at. I decided to walk away, realizing that its nothing but bullshit, when suddenly there was this huge roar in the crowd. I looked up, and in my amazement, there was actually a madman on the top of Howrah Bridge (literally, on top :P). Not only was he on top of bridge, he was actually moving around pretty freely and was waddling. I stood there, just like all the others in the herd, and stared at him.

   "Well one crazy big idiot decides to climb up the bridge, and 15k other small idiots(me included) just leave all their work and stare at the crazy man. Its a world filled with idiots after all. "


crazy guy on bridge

crazy people


I also took a video, but the quality isn't very good. Anyways, I was getting late for my train, so I left.


video


    I would suggest people to go visit the Indian Museum, especially with family. There's something for everyone's interest and is a Marvelous museum with very interesting artifacts and information about India!

    All in all, it was a fun day. Traveled in one of the most crowded cities in the country and visited the 9th oldest museum in the world, followed by the crazy bridge guy. It was tiring, but totally worth it!

Monday, July 13, 2015

Pop-up Messages: Toasts and Dialog Boxes

    A major part of an interactive user interface in any application is the feedback. Most of the times, when a user interacts with the application, he/she expects a proper response of some sort. This feedback to be user can be generated in two ways: Toasts and Dialog Boxes.


    A Toast is a simple pop-up message that appears on the screen when the user performs some action. It takes up a small space, is compact and remains visible for a short time, then disappearing automatically. The current activity remains active when the toast is displayed. Toasts are commonly used to deliver simple messages to user like "Login success" or "saved in drafts".

A Toast

    A Dialog Box on the other hand is a window that prompts the user to make a decision and choose one of the available choices. It takes up a significant amount of space and the current activity becomes inactive. Unlike a toast, a dialog box remains on screen until user makes a decision.



An Alert Dialog

Now Lets see how to make these! I'll be using these on my previous post on how to create custom buttons and reuse the code. Now instead of opening a new activity, we'll raise a toast and a dialog box.

Toasts:


    Making a toast is a pretty simple job. Firstly, we need to import the Widget.Toast class. Then Define a new Toast object. On this new toast object, we need to use the .makeText() method to define our toast. Now the .makeText() method takes three parameters: Context, message and duration.
    In the context, we'll simply pass the current context. In the message part,we'll enter the string we want to display in the toast. And in the duration part, we'll set the time period we want to display the toast for. By default, android has two inbuilt times, namely Toast.LENGTH_SHORT and Toast.LENGTH_LONG, but you can set the time you want by entering the time in millisecs.

After this, simply call the .show() method to display the toast.


1
2
3
 Toast toast;
 toast.makeText(MainActivity.this,"Hello "+nameET.getText().toString(),Toast.LENGTH_SHORT);
 toast.show();

Or, you can make the same toast in a single line ..

1
 Toast.makeText(MainActivity.this,"Hello "+nameET.getText().toString(),Toast.LENGTH_SHORT).show();


    Now by default, this toast will appear in the bottom part of your screen, that too centered. You can change the position of this toast by using the .setGravity() method. It takes 3 parameters: Gravity constant, an x-position offset, and a y-position offset. Using this method, you can position your toast anywhere on the screen.

Dialog Box:

    For creating a dialog box, first import AlertDialog library. Before showing the dialog, we need to build it. For this, we'll use AlertDialog.builder class. Instantiate a new AlertDialog.builder object an pass the current context in the constructor.

    After creating the object of this class, we can set the details of this dialog. The following 3 are the important methods that are required for creating an alert dialog.

.setTitle() - Sets the title of the Dialog Box.
.setMessage() - Sets the message that is showed in the dialog box.
.setPositiveButton() - creates the positive button for the dialog.

Apart from these three, we can also add other elements to the dialog box like a negative Button, a neutral button, icon etc. by using different methods.

    The response buttons take 2 arguments. One is the String that is to be displayed on the button, and the other is an onClickListener() object that defines the action to be taken when the button is clicked. A positive button is generally placed on the right hand side and the negative button is placed on the left hand side. Their functioning is defined by the onClick() method inside it. There is another neutral button that can be used in the dialog box, when you have to give a choice between both the positive and negative buttons. 

Note: You can only use ONE of each kind of button in the dialog box.

    After we are done defining the Dialog Box, we need to create it. For this, we need to create a new instance of AlertDialog, call the .create() method on the builder object and initialize it with this new instance.

Now whenever we need to show this dialog box, we'll call the .show() method on this new AlertDialog object.

Here's the Java code for the toast and the Dialog box:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        nameET = (EditText) findViewById(R.id.nameET);
        clearBtn = (Button) findViewById(R.id.clearBtn);
        submitBtn = (Button) findViewById(R.id.submitBtn);
        
        AlertDialog.Builder alert =new AlertDialog.Builder(this);
                alert.setMessage("No name was entered. Please enter a valid name.").setTitle("Error")
                .setNegativeButton("Exit",new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        finish();
                    }
                })
                .setPositiveButton("OK",new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                    }
                });

        final AlertDialog dialog = alert.create();

        submitBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {

                    if(nameET.getText().toString().equals(""))
                    {
                        dialog.show();

                    }
                    else
                    {

                        Toast.makeText(MainActivity.this,"Hello "+nameET.getText().toString(),Toast.LENGTH_SHORT).show();
                    }
         
                }
            });
        }

    public void clearTextBox(View v)
    {
        nameET.setText("");
    }

 And Viola!! We're done!


resulting toastresulting dialog box

Wednesday, July 8, 2015

Making Custom Buttons for Android

    When it comes to a creating a visually alluring UI, the default android buttons are pretty ugly and boring. The simple rectangular buttons with a grey background look dull. But thankfully, android provides enough customization to produce better looking buttons for the application. With a few lines of XML coding, one can produce much better looking buttons. So lets get started creating our own custom buttons!

    First we need to define our custom button. For this, we need to create a new XML file in the drawable folder (create the folder in res if it doesn't exist), lets name it button.xml. This file will contain the specifications of the custom button we are going to design.

    Now, each button has different states. It could be the case that the button is idle, the button is focused or hovered over, the button is pressed or whether is enabled or not. The <item> tag can be used to define different states of the buttons.

  • Leaving the item tag without attributes creates the default or idle state of the button. 
  • android:state_focused attribute defines what happens to the buttons when the buttons are focused at. This attribute has two values, true and false, each of which can be used to achieve more customization.
  • android:state_pressed attribute defines what happens to the buttons when the buttons are pressed. 
  • android:state_hovered attribute defines what happens to the buttons when the buttons are hovered over by the cursor. Since most devices are touch devices, one can ignore this attribute.

    After the states of the button are defined, its time to look at the properties of this button at each of this states.

<Shape> tag defines the shape of the button. Here, I have chosen Rectangular shape because its pretty standard.

Now, some properties inside the shape tag:
  • <corner> - This tag is used to edit the corners of the button. 0 dip indicates the corner is a perfect rectangular corner and increasing it will increase the curvature of the corners.
  • <stroke> - This tag defines the outline/boundary of the button.
  • <gradient> - This tag defined the color gradient of the button. by giving it  start and an end color (middle color applicable too), the button can made of this gradient colour (99colors is a good site if you need hex codes for different colours).
  • <padding> and <size> - Defines the padding and size of the button.
  • <solid> - defines the base color for the button.

This is what the final button.xml file looks like:


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >

    <item android:state_pressed="true"  >
        <shape android:shape="rectangle"  >
            <corners  android:bottomLeftRadius="0dp"
                android:bottomRightRadius="10dp"
                android:topLeftRadius="10dp"
                android:topRightRadius="0dp"  />
            <stroke android:width="2dip" android:color="#2c2f34" />
            <gradient  android:angle="-90"
                android:startColor="#6689FA"
                android:endColor="#8FA9FF"  />
        </shape>
    </item>

    <item android:state_focused="true">
        <shape android:shape="rectangle"  >
            <corners  android:bottomLeftRadius="0dp"
                android:bottomRightRadius="10dp"
                android:topLeftRadius="10dp"
                android:topRightRadius="0dp"  />
            <stroke android:width="1dip" android:color="#2c2f34" />
            <solid  android:color="#1d242c"/>
        </shape>
    </item>

    <item >
        <shape android:shape="rectangle"  >
            <corners  android:bottomLeftRadius="0dp"
                android:bottomRightRadius="10dp"
                android:topLeftRadius="10dp"
                android:topRightRadius="0dp"  />
            <stroke android:width="1dip" android:color="#2c2f34" />
            <gradient  android:angle="-90"
                android:startColor="#002088"
                android:endColor="#1337AE" />
        </shape>
    </item>

</selector>


    After the button is defined, we can directly use this in our application. To use this directly, simply set the background of the button to this xml file.

    We can improve this button further by adding text style in style.xml. Using this, we can edit the text in the button. So, we now open style.xml and add another style tag. Name the style tag as you like and then set parent as Widget.button. Then add the required item tags.



The final styles.xml looks like:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
<resources>
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
    </style>
    
    <style name="button" parent="android:style/Widget.Button">
        <item name="android:textSize">15sp</item>
        <item name="android:textStyle">bold</item>
        <item name="android:textColor">#FFFFFF</item>
        <item name="android:gravity">center</item>
        <item name="android:shadowColor">#000000</item>
        <item name="android:shadowDx">1</item>
        <item name="android:shadowDy">1</item>
        <item name="android:shadowRadius">0.6</item>
        <item name="android:background">@drawable/button</item>
        <item name="android:padding">10dip</item>
    </style>
</resources>

Add the background as the button.xml.

    And now the custom button is ready. to use it, simply add the style attribute in the button you want to customize and you're done! To change the colors, simply copy the xml code into a new xml file and change the hex codes.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
    <Button
            android:layout_width="wrap_content"
            android:layout_gravity="left"
            android:layout_height="wrap_content"
            android:text="Submit"
            style="@style/button"
            android:layout_marginRight="20dp"
            android:layout_weight="1"
            android:id="@+id/submitBtn"
     />


custom buttons default
Default buttons
pressed custom button
Submit button when pressed
    And there you go! The custom buttons are ready. They definitely look better than before, but with a little more practice, the buttons can look even better!!!